python中cmd是什么_我在cmd中运行这个python程序,什么都没有发生

首先,您需要调用函数,如前所述。我还认为从userGuess()内部调用maxNum()是有意义的,因此只需在底部调用userGuess()。在

其次,max_int只在maxNum()函数中定义,因此userGuess()无法访问该函数,您将得到一个错误。在

所以,像这样:from time import sleep

from random import randint

print("Starting up...")

def maxNum(max_int):

print("The maximum number to guess is %d" % max_int)

def userGuess():

max_int = 6

maxNum(max_int)

guess1 = int(input("Guess what number you think the dice will land on? >"))

if guess1 > max_int:

print("You chose a number higher than the maximum number allowed!")

else:

print("Rolling...")

sleep(1)

print("The number is...")

sleep(2)

print(randint(1,6))

userGuess()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值