If I want the IDE (i.e Pydroid) to return different strings based on the difference between a Variable's stored value and the other values of a given range, how would I do that? I know I can do it with Set operations, but are there any methods other wise?
For example: Let's say the game "hot or cold". If you are asked to guess a number between 0 and 10 (so, range(1,10)), and the Winning number is 4 'W=4', I want the str("Almost") to print out for input 3 or 5, the str("hot") for 2 or 6, "warm" for 1 or 7, 8 should return "cold", and "couldn't be further" for 9.
I tried:
print("Can you guess the winning
number between 0 and 10?")
A=int(input('Pleasant picks: '))
if A not in range(1,10):
print("That is not an
option...")
elif A == 4:
print("You win!")
else:
if A is int(3) or int(5):
print("Almost...")
elif A is int(2) or int(6):
print("You're hot")
elif A is int(1) or int(7):
print("Warm, but not as hot
as your mom")
elif A is int(8):
print("cold...")
elif A is int(9):
print("Couldn't be further")
else:
print(i)
It only returns "Almost" for all choices but 4 and out of range which work right...
And how do I loop this while also returning the count of attempts?
Aucun commentaire:
Enregistrer un commentaire