{"207.5,1", "373,2", "278.5,3", "9.1,1",
"9.1,9", "134,4", "277,5", "674,7", "58.5,9"}
答案 0 :(得分:1)
缩进块,更加小心!
def phone():
import webbrowser
print("Do you have an iphone or samsung?")
answer = input ('iphone/samsung:')
if answer == "iphone":
print("what type of iphone?")
answer = input ('5, 6 or 7:')
if answer == "samsung":
print("what type of samsung do you have?")
answer = input ('s5, s6 or s7:')
x = input("press enter and type in your answer. phone(), tablet() or console() ")
if x == 'phone()':
phone()
elif x == 'tablet()':
tablet()
elif x == 'console()':
console()
答案 1 :(得分:1)
基本上,你拥有的是......
def foo():
print("stuff")
answer = input("type foo()")
而answer == "foo()"
是True
。
你从未打电话给foo()
,但你只是把它作为一个字符串输入。
你需要运行它。
exec(answer)
但是,exec
非常糟糕,所以相反,您应该使用if
和elif
来调用相应的函数。
if answer == 'foo()':
foo()