[問題] 新手發問

看板Python作者 (JOY)時間4年前 (2020/05/08 12:56), 編輯推噓5(504)
留言9則, 6人參與, 4年前最新討論串6/6 (看更多)
大家好, 目前看彭彭老師的youtube videos學習python,目前學習到if判斷式 我跟著老師打的程式出現了錯誤無法正確跑完,煩請大家教導我哪裡出錯,謝謝 以下為程式碼 x=int(input('enter a number: ')) y=int(input('enter a number: ')) op=input('enter an operator: +, -, *, /: ') if op=='+': print(x+y) elif op=='-': print(x-y) elif op=='*': print(x*y) elif op=='/': print(x/y) else: print('not an operator') 輸入完兩個數值及運算子後,出現以下訊息, enter a number: 6 enter a number: 8 enter an operator: +, -, *, /: / Traceback (most recent call last): File "condition2.py", line 3, in <module> op=input('enter an operator: +, -, *, /: ') File "<string>", line 1 / ^ SyntaxError: unexpected EOF while parsing 請問我改如何修改讓程式繼續跑下去呢? 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 47.184.77.89 (美國) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1588913796.A.A72.html

05/08 13:25, 4年前 , 1F
你是不是用到 Python 2 了? Python 3 才會正常喔
05/08 13:25, 1F

05/08 13:28, 4年前 , 2F
正在用 python2 ? 請務必改用 python3 來學習
05/08 13:28, 2F

05/08 13:33, 4年前 , 3F
我下載的是3.8
05/08 13:33, 3F

05/08 13:45, 4年前 , 4F
用 python 3吧 官方的維護主力在3.X 以後的版本
05/08 13:45, 4F

05/08 13:48, 4年前 , 5F
你是不是用蘋果電腦,它本身內建2.7版本,就算灌了3.6
05/08 13:48, 5F

05/08 13:48, 4年前 , 6F
版本。設定值沒設好,還是用2.7在跑
05/08 13:48, 6F

05/08 13:54, 4年前 , 7F
對,我剛剛檢查了,terminal顯示的是python2,我以為我
05/08 13:54, 7F

05/08 13:54, 4年前 , 8F
安裝好了,感謝大家提點
05/08 13:54, 8F

05/08 18:01, 4年前 , 9F
我還是習慣用python2.7...Y
05/08 18:01, 9F
文章代碼(AID): #1UjEQ4fo (Python)
文章代碼(AID): #1UjEQ4fo (Python)