Answer the question
In order to leave comments, you need to log in
How to do a search for one of the elements of a dictionary in a list?
Hi all. how to make a search condition for an element from a dictionary in a string?
example:
cmds={
"Liza":("лиза","лизочка"),
"vrema":("который сейчас час", "сколько сейчас время")
"pogoda":("какая погода на улице", "какая на улице погода")
}
text="лиза сколько сейчас время"
if "vrema" in text: #если в строе есть элемент списка "vrema"
print(12:00)
if "pogoda" in text: #если в строе есть элемент списка "pogoda"
print(15 градусов)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question