username=input()
print("\nComand using '@,!,$' - Ex: @Hi, !Melon, $Google.\n")
Menu = {"Chat": ['Hi','Hello', 'Bye']
,"Songs": ['Melon','Bugs','Spotify']
,"Search": ['Google','Daum','Naver']
}
print(Menu)
while True:
myorder = input()
if myorder.startswith('@'):
print(myorder[1:] + ' ' + username + '.' )
continue
elif myorder.startswith('!'):
print('myorder[1:] + ' is a Music application.')
continue
elif myorder.startswith('$'):
print('myorder[1:] + ' is a Website.')
continue
elif print('Please enter your order in a valid form'):
continue
I am practicing while studying Python, and I have a question. How do I make it possible to print when I write username and then my order only writes (Hi or Hello) in the list in the Menu (Dictionary)? If you look over there, there's Hi, Hello, Bye. If you do @Hi, it becomes "Hi username", but since there's no Halo, what should I do to prevent printing?
python
Only when myorder is on the list in Chat in the Menu
You can translate this into Python.
if myorder in Menu["Chat"]:
# # do your work
By the way, the comparison is not my order, but you will have to exclude the first @ from the input of my order,
if myorder[1:] in Menu["Chat"]:
# # do your work
© 2024 OneMinuteCode. All rights reserved.