From Python Dictionary
A = { 'Nice to meet you':hi, 'Hello':bye} If there is, can I input the key value as input and output only the corresponding value?
python
Hello!
A = { 'Nice to meet you' :'hi', 'Hello' :'bye'}
If you type user_input = input() # 'Hello',
print(A[user_input]) # 'bye' is output
# How to turn the loop...
for k, v in A.items() :
if user_input == k:
print(v) # 'bye' is displayed
Have a nice day.
------- Add-------
A = { 'Nice to meet you' :'hi', 'Hello' :'bye'}
For_in range(2): # Number of times you want to repeat: #2
If you type user_input = input() # 'Hello',
print(A[user_input]) # 'bye' is output
© 2025 OneMinuteCode. All rights reserved.