Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Input does not matter, it always goes to Twitter?

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..

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading