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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • am5243
    New Member
    • Sep 2015
    • 3

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

    Code:
    import random
    
    print('Welcome to Guess the Number')
    print('Try to guess the number in as few tries as possible')
    
    the_number= random.randit(1, 100)
    
    guess=int(input('Take a guess!  '))
    tries=1
    
    
    while guess != nbum:
              if guess>the_number:
                  print('Lower... ')
    
    
    else:
              print('Higher... ')
    
    
    guess= int(input('Take a guess!  '))
    tries+=1
    
    print('Well done! The number was', the_number)
    print('and it only took u=you', tries, 'tries!')
    
    input('n/nPress the enter key to exit')
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

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

    You're probably looking for randint.

    Comment

    • am5243
      New Member
      • Sep 2015
      • 3

      #3
      Thanks! I tried that and it worked straight away :)

      Comment

      Working...