input函数,类似Java的scanner,获取用户输入,str。他可以接受一个参数作为提示
同样也有eval函数,去执行一段代码
对于多个并列list迭代时,可以用zip组成一个元组去执行,感觉更清晰
我的代码
for i in range(len(names)):
print(msg.format(names[i], assignments[i], int(grades[i]) , int(grades[i]) * 2))
示例代码
for name, assignment, grade in zip(names, assignments, grades):
print(message.format(name, assignment, grade, int(grade) + int(assignment)*2))
还是有很长路要走~
网友评论