相同的输出在循环中重复
为什么我的程序仅在终端中显示代码u = float(“输入字母'u':”的值)的行?)?
B=0
A=0
U=0
while(U == 0):
U=float(input( "Enter the value of the letter 'U' :" ))
ent=[200,101,255,11]
for i in ent:
A = A + (i * ( 1 -(1/10**2) ) / 255) -1/(10**2)
B = B + i
print(B)
该程序在终端中的输出是:
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 9
4536
Process finished with exit code 0
Why does my program only show the line of code U=float(input( "Enter the value of the letter 'U' : " )) in the terminal?
B=0
A=0
U=0
while(U == 0):
U=float(input( "Enter the value of the letter 'U' :" ))
ent=[200,101,255,11]
for i in ent:
A = A + (i * ( 1 -(1/10**2) ) / 255) -1/(10**2)
B = B + i
print(B)
The output of the program in the terminal is this:
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 0
Enter the value of the letter 'U' : 9
4536
Process finished with exit code 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎您需要
通过再提供一个选项卡来修复“打印(b)”行上的凹痕,您每次用户输入某些内容时都会打印出来,并且使用一个选项卡,您将为数组中的每个值打印一个选项卡!
例如,通过将 print()内部的用于循环,将显示变量b 4次(由于 ent 变量)每次用户插入一个数字:
it seems like you need to fix indentation on the "print(B)" line
By giving one more TAB you will be printing each time the user inputs something, and with one more TAB you will be printing for each value inside your array!
For example, by having print() inside the for loop, the variable B will be shown 4 times (due to the ent variable) each time the user inserts a number: