import webbrowser
T = "www.twitter.com"
R = "www.reddit.com"
Y = "www.youtube.com"
while True:
print('Enter T for Twitter')
print('Enter R for Reddit')
print('Enter Y for Youtube')
input()
if (T):
webbrowser.open_new("www.twitter.com")
break
elif (R):
webbrowser.open_new("www.reddit.com")
break
elif (Y):
webbrowser.open_new("www.youtube.com")
break
else:
print('Invalid selection, try again.')
continue
What am I missing? I'm sorry if the answer is obvious, i'm new to Python3 and have been trying for hours..
CodePudding user response:
import webbrowser
T = "www.twitter.com"
R = "www.reddit.com"
Y = "www.youtube.com"
print('Enter T for Twitter')
print('Enter R for Reddit')
print('Enter Y for Youtube')
a=input()
while True:
if a in "Tt":
webbrowser.open_new("www.twitter.com")
break
elif a in "Rr":
webbrowser.open_new("www.reddit.com")
break
elif a in "Yy":
webbrowser.open_new("www.youtube.com")
break
else:
print('Invalid selection, try again.')
Try this code.