老化工作的小代码语法错误

Syntax error on small code for ageing work

lst = []
num = int(input('How many people?: '))
for n in range(num):
 age = float(input('Input Age: ')
  seconds = str(age*31536000)

print("You lived: ", seconds)
lst.append(age)

print("Highest age: ", max(lst), "\n Least aged: ", min(lst))

我不知道为什么这不起作用,感谢任何帮助。

您忘记关闭第 4 行的括号。lst.append 之前的打印语句可能应该在循环中(图片来源:Luke Nelson)。这是固定代码:

lst = []
num = int(input('How many people?: '))
for n in range(num):
 age = float(input('Input Age: '))
 seconds = str(age*31536000)
 print("You lived: ", seconds)
 lst.append(age)

print("Highest age: ", max(lst), "\n Least aged: ", min(lst))