Let’s write a game. It would be the easist possible Python game. Try to guess the number between 1 and 10. The quicker you guess the better the score will be. See how to write such code.
from random import randint rand = randint(1, 10) answer = -1 i = 0 print("Guess the number 1 - 10") while answer != rand: i += 1 answer = int(input("Enter your number: ")) if answer > rand: print("Crap, your number is too high") elif answer < rand: print("Crap, your number is too low") print("Nice! You guessed after", i, "time.")
To write such game you need to random generate the number thanks to random module. Randint will generate integer between 1 and 10. With the simple while iteration and if, elif, condition you will proceed with guessing the number.
Such code is the best way to learn Python coding. Try to change the code, write different iteration and conditions to play with the code and gain Python experience. Good luck (with the game and Python skills) 😉