Reputation: 29
Here is the code:
import random
secretNumber = random.randit(1, 20)
print("I'm thinking of a nummber between 1 and 20.")
for guessesTaken in range(1, 7):
print("Take a guess.")
guess = int(input())
if guess < secretNumber:
print("Your guess is to low")
elif guess > secretNumber:
print("Your guess is to high")
else:
break # This condition is the correct guess!
if guess == secretNumber:
print("Good job! You guessed my number in " + str(guessesTaken) + "guesses!" )
else:
print("Nope.The number I was thinking of was " + str(secretNumber))
This is the problem :
"AttributeError: module 'random' has no attribute 'randit'"
I tried to change the name of the file from "test.py" which was the first name of the file and then in "guessTheNumber.py" but still didn't works.
Upvotes: 1
Views: 6915
Reputation: 175
Wrong spelling. Maybe what you wanted is:
secretNumber = random.randint(1, 20)
It should be randint(1,20)
not randit(1,20)
Upvotes: 1