用户输入编号并使用python中的循环分配给不同的变量
我尽力在不同的论坛上找到它,所以请原谅我很容易。
我想从用户中获取不同的输入,并将其分配给不同的变量。 使用split()我们只能在一行中输入输入。
w,x,y,z = (input('Enter the number :').split(','))
但是,我们如何要求不同行中的输入并将其分配给变量,而无需再次键入输入函数。
我想要与下面代码相同的输出,但没有多次输入输入功能。
w= int(input('Enter the number :'))
x= int(input('Enter the number :'))
y= int(input('Enter the number :'))
z= int(input('Enter the number :'))
I tried my best to find it on different forums so excuse me if it is an easy one.
I want to take different inputs from the user and assign them to different variables.
Using split() we can only enter the inputs in one line.
w,x,y,z = (input('Enter the number :').split(','))
But how can we ask for inputs in different line and assign them to the variables without typing the input function again.
I want the same output as below code but without typing input function multiple times.
w= int(input('Enter the number :'))
x= int(input('Enter the number :'))
y= int(input('Enter the number :'))
z= int(input('Enter the number :'))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一个解决方案可以输入4个数字,然后将它们分配给变量。例如:
打印:
或:
One solution can be input 4 numbers to array and then assign them to variables. For example:
Prints:
Or: