為什么我的程式在終端只顯示代碼行 U=float(input("Enter the value of the letter '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
uj5u.com熱心網友回復:
看來您需要修復“print(B)”行上的縮進
通過再給一個 TAB,您將在用戶每次輸入內容時列印,再給一個 TAB,您將為陣列中的每個值列印!
例如,通過在for 回圈中使用print() ,每次用戶插入數字時,變數 B 將顯示4 次(由于ent變數):
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)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/492953.html
標籤:Python python-3.x
下一篇:OSError:[Errno22]Invalidargumentpythonsocketconnection問題
