[英]Simple python program ran into infinite loop
我正在嘗試制作一個簡單的XOR程序。 一旦檢查完語法,便運行程序並進入無限循環。 我找不到我的錯誤。 救命?
def disencode(n):
seconde = raw_input("Input_Second_String")
y = len(n)
x = 0
while x < y:
if n[x] == seconde[x]:
print 0
else:
print 1
x =+1
disencode(raw_input("Input_First_String"))
x=+1
應該是x += 1
,就像您當前的代碼一樣,您永遠不要遞增x,因為x = + 1與x = 1是相同的。
您實際上將x設置為1,從不增加它,並要求循環在x <y無限大時運行。
使用x += 1
來遞增x
而不是x =+1
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.