So, Im a complete newb when it comes to programming. I have been watching tutorials and I am reading a book on how to program python. So, I want to create a number generator guesser on my own and I have watched some tutorials on it but I do not want to recreate the code. basically, I want to make my own guesser with the information I've gotten.
import random
# Random Numbergenerator Guesser
print("Hello and welcome to the random number guesser.")
print("I am guessing a number of 1 - 20. Can you guess which one?")
x = random.randint(1,20)
# Here you guess the number value of 'x'
for randomNumber in range (1,7):
randomGuess = input()
if randomGuess > x:
print("Too high. Guess again!")
elif randomGuess < x:
print("Too low. Guess again!")
else:
break
# Checks to see if the number you were guessing is correct or takes you to a fail screen.
if randomGuess == x:
print("Correct number!")
else:
print("Too many tries. You have failed. The number I was thinking of was " + (x))``
I keep getting this error.
C:\Python\Python35\python.exe "C:/Users/Morde/Desktop/Python Projects/LoginDataBase/LoginUserDatabse1File.py"
Hello and welcome to the random number guesser.
I am guessing a number of 1 - 20. Can you guess which one?
1
Traceback (most recent call last):
File "C:/Users/Morde/Desktop/Python Projects/LoginDataBase/LoginUserDatabse1File.py", line 12, in <module>
if randomGuess > x:
TypeError: unorderable types: str() > int()
Aucun commentaire:
Enregistrer un commentaire