[Solved] Game code error line skipping – Python [closed]


I think the problem is here:

r = str(input('{} please enter a integer between 1 and 10: '.format(name)))

r = str(input('{} please enter a integer between 1 and 10: '.format(name2)))

Don’t you mean to assign to p the second time through? p = str(...

Also, these lines don’t make much sense:

elif (r > 'r1' and p < 'r1'):
    print('Computer chose', r1, ' both of you loose')
elif (r < 'r1' and p < 'r1'):
    print('Computer chose', r1, ' both of you loose')
elif (r > 'r1' and p > 'r1'):
    print('Computer chose', r1, ' both of you loose')
elif (r < 'r1' and p > 'r1'):
    print('Computer chose', r1, ' both of you loose')

You’re comparing r and p to the string 'r1'. You probably mean to be comparing to r1 itself, but even then the logic is really strange. I think you just want if r != r1 and p != r1, but the below is much simpler:

if r == p:
    print('Plz choose different numbers from each other')
elif r == r1:
    print('Computer chose', r1,',',name,' Wins!')
elif p == r1:
    print('Computer chose', r1,',',name2,' Wins!')
else:
    print('Computer chose', r1, ' both of you loose')

(Note, though, that the word is spelled “lose.”)

UPDATE

You probably want integers:

r = int(input('{} please enter a integer between 1 and 10: '.format(name)))

r = int(input('{} please enter a integer between 1 and 10: '.format(name2)))

7

solved Game code error line skipping – Python [closed]