manvir singh manvir singh - 1 month ago 14
Python Question

After the first phone() why doesn't the it work?

print("what type of device do you have phone, tablet or laptop(put brackets at the end of your answer)?")

answer = input ("press enter and type in your answer. phone(), tablet() or console()")

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:')

Answer

Indent block, be more careful!

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()