如何打印值列表?

2024-09-24 10:17:02 发布

您现在位置:Python中文网/ 问答频道 /正文

print("Hello. Please Proceed to Enter a Range of Numbers")
first = int(input("please enter the first number in the range: "))
last = int(input("please enter the last number in the range: "))

numlist=list(range(first,last)

我在解析时遇到一个错误,预期为eof。当我加入print(numlist) 它增加了一个额外的错误


Tags: theinnumberhelloinput错误rangeint
1条回答
网友
1楼 · 发布于 2024-09-24 10:17:02
print("Hello. Please Proceed to Enter a Range of Numbers")
first = int(input("please enter the first number in the range: "))
last = int(input("please enter the last number in the range: "))

numlist=list(range(first,last)) #FTFY
for x in numlist:
   print(x)

本质上,这是在声明numlist之后,它遍历它并在新行上打印出每个值

你的主要问题是你错过了numlist声明中的第二个RPAREN

相关问题 更多 >