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 <module>
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?