#17787: python新手,請各位大德指教


movingwall (movingwall)


a=1
while a==1:
b=input()

print("hello",b)

請問各位前輩為甚麼這樣子print不出東西
#17794: Re:python新手,請各位大德指教


stevenshih89@gmail.com (一步一步慢慢爬)


a=1
while a==1:
b=input()

print("hello",b)

請問各位前輩為甚麼這樣子print不出東西

 

有幾個要修改的地方

1.輸入方法

你這樣做迴圈會一直跑下去,最後會出錯。

要這樣才行

while True:

    try:

        程式碼

    except: break

 

2. print的位置

print要放在迴圈裏面,因為while迴圈會一直在裡面執行(不會出來),因此你的寫法會做不到print的那一行

 

就這樣

哎呀!這個程式碼好想秀出來喔!簡單多了

咳咳!年輕人啊,我在教你釣魚阿,我不會直接把幫你釣魚喔!

請你把這題做出來吧!