2017-11-03 4 views
-1

変数xと変数yの値を見つけようとしていますが、正しく分割できません。私はいつもz変数に関係するエラーを受け取ります。if文がHTML/Javascriptのチェックボックスを使用して

x = str(input("What was your total: ")) 
y = str(input("What percentage of a tip would you like to give (15 or 20): ")) 
z = float(x/y) 

print("The tip you will want to give will be: " + z) 

input("\n\nPress the enter key to exit") 
+3

'X'と 'y'は文字列です。あなたはそれらを分けることはできません。 – DavidG

+0

z = float(x/y)TypeError:/: 'str'および 'str'のサポートされていないオペランドタイプ –

答えて

0

修正されたバージョン:

x = int(str(input("What was your total: "))) 
y = int(str(input("What percentage of a tip would you like to give (15 or 20): "))) 
z = float(x/y) 

print("The tip you will want to give will be:", z) 

input("\n\nPress the enter key to exit")