By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,960 Members | 990 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,960 IT Pros & Developers. It's quick & easy.

AttributeError: 'module' object has no attribute 'randit'

P: 3
Expand|Select|Wrap|Line Numbers
  1.  
  2. import random
  3.  
  4. print('Welcome to Guess the Number')
  5. print('Try to guess the number in as few tries as possible')
  6.  
  7. the_number= random.randit(1, 100)
  8.  
  9. guess=int(input('Take a guess!  '))
  10. tries=1
  11.  
  12.  
  13. while guess != nbum:
  14.           if guess>the_number:
  15.               print('Lower... ')
  16.  
  17.  
  18. else:
  19.           print('Higher... ')
  20.  
  21.  
  22. guess= int(input('Take a guess!  '))
  23. tries+=1
  24.  
  25. print('Well done! The number was', the_number)
  26. print('and it only took u=you', tries, 'tries!')
  27.  
  28. input('n/nPress the enter key to exit')
  29.  
  30.  
Sep 22 '15 #1

✓ answered by Rabbit

The error message is correct, there is nothing named randit in the random module.

You're probably looking for randint.

Share this Question
Share on Google+
2 Replies


Rabbit
Expert Mod 10K+
P: 12,347
The error message is correct, there is nothing named randit in the random module.

You're probably looking for randint.
Sep 22 '15 #2

P: 3
Thanks! I tried that and it worked straight away :)
Sep 23 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Browse more Python Questions on Bytes