The Guessing Game!
This is the guessing game, you must guess the computer's number. There are 2 rounds and well the description is told to you in the game.. Give some suggestions and feedback on the game, I am a beginner so yeah!
hello! cool program! instead of just picking a random number for the code this can be done! :
import random import os num = random.randint(1,100)#can be more than just a hundred # something to spice it up: guesses = 15#edit this to your liking print(num) for i in range(guesses): num_guess = int(input("What is your guess?\n>")) try: if num_guess > num: os.system('clear') print("Too high!\nYou have "+str(guesses)+" more guesses!") guesses = guesses - 1 elif num_guess < num: os.system('clear') print("Too low!\nYou have "+str(guesses)+" More guesses") guesses = guesses - 1 else: os.system('clear') print("You got it!\nWith "+str(guesses)+" guesses left!") break guesses = guesses - 1 except: os.system('clear') print("Enter a number!!") break if guesses == 0: print("Oh no! You ran out of guesses!! The number was: "+str(num))
str() basically tells python it is a string, because if you just put
variable = 1234 print("Hello, "+variable)
That will generate an error, because python thinks you are trying to add the string
Hello, with the number
1234 which is impossible.
Thanks for reading!!
Also line 34 there is an extra
I cant talk to you anymore, cya in 2 months