0
How
Whenever I input 'YouTube' it opens YouTube But whenever I input something else then also it opens YouTube Plz help https://code.sololearn.com/cK8MQy1jy9U7/?ref=app
6 Answers
+ 2
Please upload your code, steps are given below:
https://www.sololearn.com/post/75089/?ref=app
Seem like you are working on virtual assistant.
+ 2
input = input(text78)
Avoid using 'input' as variable name, it's a built-in method name for reading user input. Use other name, for example <query>. And convert the input into lowercase for ease of comparison.
query = input( text78 ).lower()
When comparing the input, just use lowercase string to check against, because we have converted user input into lowercase letter form in <query>
if "youtube" in query:
# open YouTube
elif "google" in query:
# open Google
One more thing - you need to read user input on the inside of the while...loop rather than on the outside. Otherwise your code reads user input once only, and reads that over and over again - which probably be the reason it is doing the same thing again and again.
while True:
query = input().lower()
if not query:
break
# check <query> with if ... elif
+ 1
đ§Somyađč
Sorry, Now you can view.
+ 1
E ~ J
Now you can view the code