Learning recursion, error message(non-default argument follows default argument) python

后端 未结 1 978
青春惊慌失措
青春惊慌失措 2021-01-29 04:34

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

相关标签:
1条回答
  • 2021-01-29 04:57

    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.

    0 讨论(0)
提交回复
热议问题