AttributeError:"module"对象没有属性"randit"

选择 | 换行 | 行号
  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.  
# 回答1

错误消息是正确的,随机模块中没有名为randit的内容。你可能在找兰丁。
# 回答2

谢谢我试了一下,结果很快就奏效了:)

标签: python

添加新评论