PYTHON问题:为什么我的代码显示;无”;第9行何时执行?有人能帮我吗?
这是我现在正在使用的代码。。。 当我执行第9行时,我遇到了这样的错误,我需要修复什么 :- 输入数字,无论数字是什么 输入从这里开始 把你的函数改成这个PYTHON问题:为什么我的代码显示;无”;第9行何时执行?有人能帮我吗?,python,Python,这是我现在正在使用的代码。。。 当我执行第9行时,我遇到了这样的错误,我需要修复什么 :- 输入数字,无论数字是什么 输入从这里开始 把你的函数改成这个 print()是一个函数。它在您的案例中不返回任何内容(None)。 input()函数认为这个None对象值得在控制台上显示 因此,在进行任何输入之前,屏幕上不会显示任何内容。有几个问题: 1) mainSystem()函数的input()中有一个错误的print() 2) 您可能希望使用f字符串来打印正确的数字,而不是字符串文字“numb
print()
是一个函数。它在您的案例中不返回任何内容(None
)。
input()
函数认为这个None
对象值得在控制台上显示
因此,在进行任何输入之前,屏幕上不会显示任何内容。有几个问题: 1) mainSystem()函数的input()中有一个错误的print() 2) 您可能希望使用f字符串来打印正确的数字,而不是字符串文字“number”
def mainSystem():
数字=1
userInput=int(输入(“输入列表的大小:”)
如果用户输入>0:
对于范围内的x(0,用户输入):
变量=int(输入(f“输入数字{number}:”)
数字=数字+1
追加(变量)
删除print()
,为什么决定在此处添加print
,而不使用其他input()
调用?使用f字符串或字符串格式或字符串连接来构造提示。
print("\tWELCOME TO DRY_RUN CLASS ASSAIGNTMENT!\t")
userList = []
def mainSystem():
number = 1
userInput = int(input("Enter the size of the List: "))
if userInput > 0:
for x in range(0, userInput):
variable = int(input(print("Enter number",number )))
number = number + 1
userList.append(variable)
else:
print("Number should not be less than or equal to '0'!")
def maxAll():
maxofall = 0
for element in userList:
if element > maxofall:
maxofall = element
print("The maximum number is:", element)
while True:
mainSystem()
askUser = int(input("What do you want to do with the numbers?\n1.Max All\n2.Average\n3.Quit\nYour answer: "))
if askUser == 1:
maxAll()
def mainSystem():
number = 1
userInput = int(input("Enter the size of the List: "))
if userInput > 0:
for x in range(0, userInput):
variable = int(input("Enter number {} : ".format(number) ))
number = number + 1
userList.append(variable)
else:
print("Number should not be less than or equal to '0'!")