我运行后显示语法错误
Python 3.10.10 (tags/v3.10.10:aad5f6a, Feb 7 2023, 17:20:36) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
import random
#python学习交流群:660193417###
bot=int(input('Set range bottom\n'))
top=int(input('Set range top\n'))
rand=random.randint(bot,top)
print ('Random number in ['+str(bot)+','+str(top)+'] generated!')
num=int(input('###Guess the number###\n'))
cnt=1
while (num!=rand):
if (numprint('*_* Lower than the answer')
else:
print('T_T Higher than the answer')
num=int(input('###Guess the number###\n'))
cnt=cnt+1
print('^_^ You get the answer with [%d] times'%cnt)
去掉上面哪些提示信息即可,修改如下:
import random
bot=int(input('Set range bottom\n'))
top=int(input('Set range top\n'))
rand=random.randint(bot,top)
print ('Random number in ['+str(bot)+','+str(top)+'] generated!')
num=int(input('###Guess the number###\n'))
cnt=1
while (num!=rand):
if (num<rand):
print('*_* Lower than the answer')
else:
print('T_T Higher than the answer')
num=int(input('###Guess the number###\n'))
cnt=cnt+1
print('^_^ You get the answer with [%d] times'%cnt)