[英]How can I have the user input only 5 integers/strings a into a list?
My class is starting to add lists into our code.我的班级开始将列表添加到我们的代码中。 I understand how to have the user input information and loop it forever until the user types 'n' (or something like that) thus exiting the program.我了解如何让用户输入信息并永远循环,直到用户输入“n”(或类似的东西)从而退出程序。
My part of my current assignment is to have the user input 5 exam scores, store the scores into a list, and then display the list.我当前作业的一部分是让用户输入 5 个考试分数,将分数存储到列表中,然后显示列表。
How do I have the user input type in ONLY 5 exam scores and store it into a list?如何在仅 5 个考试分数中输入用户输入类型并将其存储到列表中?
Thank you fellow programmers for helping a new student to the coding world.感谢各位程序员帮助一个新学生进入编码世界。
请参阅有关 Python 中for
循环的文档: https : //wiki.python.org/moin/ForLoop
import sys导入系统
def main(): print sys.argv def main(): 打印 sys.argv
if__name__ == ' main ': main() if__name__ == ' main ': main()
Add the command line argument that you want to the list将您想要的命令行参数添加到列表中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.