i= input('Which multiplication table would you like?')print('Here is your table')j=0while j<9:j = j + 1print(i,'x',j,'=',i*j,'\t')
3 回答

收到一只叮咚
TA貢獻1821條經驗 獲得超5個贊
因為input輸入函數返回的是字符串類型的數據,所以i是字符串類型,因此,需要把輸入的值的類型轉為int型,把i= input('Which multiplication table would you like?')改成i=int(input('Which multiplication table would you like?'))就行了.
完整的改完后的Python程序如下
i = int ( input ( 'Which multiplication table would you like?' )) print ( 'Here is your table' ) j = 0 while j< 9 : j = j + 1 print (i, 'x' ,j, '=' ,i * j, '\t' ) |
添加回答
舉報
0/150
提交
取消