Higher or lower python program keeps printing 'builtin_function_or_method' is not iterable?

lives = 2wins= 0#the list of numbers to randomly pick fromsequence= [1, 2, 3 ,4 ,5 , 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]nextno= r

lives = 2
wins= 0
#the list of numbers to randomly pick from
sequence= [1, 2, 3 ,4 ,5 , 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]
nextno= random.choice(sequence)
print("starting number is", nextno)
user= input(" Is the next number Higher (H) or Lower (L)? ")
user= user.upper()
prev_no= nextno
nextno= random.choice(sequence)
sequence.remove(nextno)
print("next number", nextno)
h= "H"
l= "L"
if h in user:
while nextno >= prev_no:
wins = wins + 1
break
if l in user:
while nextno <= prev_no :
wins = wins + 1
break
else:
lives = lives - 1
print("you have", lives,"lives left")
#if the next number is lower they lose a life
#if the next numer is higher and not lower as they said they lose a life
while wins < 5 and lives != 0:
nextno= random.choice(sequence)
sequence.remove(nextno)
print("starting number is", nextno)
user= input(" Is the next number Higher (H) or Lower (L)? ")
user= user.upper
prev_no= nextno
nextno= random.choice(sequence)
sequence.remove(nextno)
print("next number", nextno)
if h in user:
while nextno >= prev_no:
wins = wins + 1
break
if l in user:
while nextno <= prev_no:
wins = wins + 1
break
else:
lives = lives - 1
print("you have", lives,"lives left")
#if the next number is lower they lose a life
#if the next numer is higher and not lower as they said they lose a life

if lives == 0:
print("You lost both lives youre out")
elif wins == 5:
print("You won!!")
.........................................
That's the program and I mport random is there
...................................
starting number is 12
Is the next number Higher (H) or Lower (L)? L
next number 16
starting number is 20
Is the next number Higher (H) or Lower (L)? H
next number 1
Traceback (most recent call last):
File "U:\GCSE.Computer science\Python\Homework\Challenge 14.py", line 43, in
if h in user:
TypeError: argument of type 'builtin_function_or_method' is not iterable
........................
that's the out put, whats gone wrong in the second part?

or:lives = 2wins= 0#the list of numbers to randomly pick fromsequence= [1, 2, 3 ,4 ,5 , 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]nextno= random.choice(sequence)print(\"starting number is\


or:Haven't read the whole code (it looks terrible), but the error is in line 34.user = user.upper means you define user to be the FUNCTION uppercase. Adding brackets () at the end activates the function as intended.Get an IDE so you can debug the code and actually see where the user changes to the non-iterable type.

Tags:sequence,