简体   繁体   中英

Python if input statements with similar sentences

I am currently trying to get a voice assistant kinda thing going for which i need to test for a variable in a Sentence, for example

"What will the weather be in 'cityname'"

. The basic thing i kind of figured out with this:

if 'What' in Sinput and... Sinput is a list with the Input words, better ways are welcome.

But the only problem is that when i do a second if statement which goes for

"What will the weather be in 'cityname' tomorrow "

, both statements will be run and i have yet to find the workaround for this!

This is simply because two if statements can't work together. You need to do your first if statement and then do an elif statement as many times as you have commands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM