I am learning python and want to learn from my mistake instead of just look at the course answer to this task.
I am trying to make a gamelist game. We have a list gamelist = [1,2,3] and the user will then get the opportunity to change a value in the list. The user will be able to choose between 0-2 (index position in the list) and after the user will be able to input a value. After this iteration, the gamelist will update.
My problem:
- I am able to change index position 2 and 1 but not 0.
- And I can do it in the sequence [2][1] but I cant change the gamelist if I got the other way around.
Code:
def userindextry():
    User_input = 'u'
    index_range = range(0,3)
    range_check = False
    while User_input.isdigit() == False and range_check == False:
        User_input = input('Please enter a number: ')
        if User_input.isdigit() == True:
            if int(User_input) not in index_range:
                User_input.isdigit() == False
                range_check == False
                print('not in range')
            else:
                print('You choosed', User_input)
                break
            
        
        else:
            print('Number please')
    return(int(User_input))
def uservalue():
    input_value = input('Please enter a value: ')
    return(input_value)
and
def game():
    gamelist = [1,2,3]
    while True:
        userindex = userindextry()
        userV = uservalue()
        for i in range(len(gamelist)):
            number = gamelist[i]
            if number == userindex:
                gamelist[number] = userV
        cmd = input('Do you want to quit? Enter \'q\'!')
            
        if cmd == 'q':
            print('You did now Quit')
            break
        else:
            pass
        print(gamelist)
game()
What is going wrong with my code?
 
     
    