2015-11-25 40 views
0

我已經將它固定到了它所需要的程度,但是我似乎無法得到的一件事就是我正在發言。代碼需要倒數第2層到第6層的樓層,包括倒數第2層。我的房子只能從下樓到下樓,比如說從3樓到6樓。我需要幫助來解決這個問題。倒數樓層

floor = int(input('Current floor: ')) 
destination = input('Desination floor: ') 
while floor <= 5: 
    floor = floor + 1 
    print(floor) 
+0

你想在javascript中做到這一點 – lyndact

+0

大聲笑....沒辦法,無論如何。 :) –

回答

0

在您增加樓層之前打印(floor = floor + 1)。你離開while循環5,我認爲它應該是目的地。最後的print或者對while循環的修改可能是需要的。

+0

謝謝你,感謝你的時間幫助我。 –

+0

跳得太快了。現在有另一個問題。我有這樣的代碼:floor = int(input('Current floor:')) destination = input('Desination floor:') while floor <= 6: print('Level'+ floor) floor =現在樓層:3 期望樓層:6 回溯(最近呼叫最後): 文件「program.py」,第4行,在 print ('Level'+ floor) TypeError:不能將'int'對象隱式轉換爲str –

+0

@StuartWalsh您正試圖組合一個字符串和一個整數。將int轉換爲str() – qwr