Trying to practice learning recursion. The program is designed to go through the list and print out the location of the chosen letter. I also don\'t understand what this error m
The issue is on this line:
get_position(pos = 0,List,letter = 'o')
Notice that you give the List
argument, a non-default argument, after default argument pos = 0
. This is not allowed. Try reordering your arguments:
get_position(List, pos = 0,letter = 'o')
To understand why this is not allowed, think about this: how would you call get_position
and pass in the second argument without passing in the first argument? You can think of some ways a language could support this, such as allowing calls like get_position( , myList)
, but to my knowledge there is no language that does.