+ 1

How would I do this? ( mock code in description )

list=['uh', 'yeet', 'meat'] Usersinput = input(say thing) If word from list is in Userinput: Dothing()

20th Jan 2019, 1:38 AM
Cameron Welker
9 ответов
20th Jan 2019, 2:21 AM
David Ashton
David Ashton - avatar
+ 6
hi, the code would look like this: things = ['one', 'two', 'three', 'four'] txt = input("Enter a number in letters: ") for word in things: if word == txt: print("Found ", word) it is pretty straight forward, simple elements, if you need more explanations on it just let me know.
20th Jan 2019, 2:11 AM
notqueued
notqueued - avatar
+ 4
You could also simply do: list = ["Item1", "Item2", "Item3"] txt = input("Sample text") if (txt in list): print("txt in list!") This isn't item specific though.
20th Jan 2019, 2:20 AM
Dread
Dread - avatar
+ 2
Thanks notqueued !
20th Jan 2019, 2:13 AM
Cameron Welker
+ 1
David Ashton so far I like the way you've done it, i'm a slow learner so right now I'm trying to understand how it works.
20th Jan 2019, 2:24 AM
Cameron Welker
+ 1
David Ashton is this the proper way to use this with multiple lists? https://code.sololearn.com/cQuMBp6mYe0d/?ref=app
20th Jan 2019, 2:35 AM
Cameron Welker
+ 1
Cameron Welker That's exactly right. I wrote this code recently using the same principles https://code.sololearn.com/cbV3CNmUih0C/?ref=app
20th Jan 2019, 3:13 AM
David Ashton
David Ashton - avatar
+ 1
David Ashton Thank you for all the help! :)
20th Jan 2019, 3:19 AM
Cameron Welker
+ 1
Cameron Welker You're welcome! 😊
20th Jan 2019, 5:59 AM
David Ashton
David Ashton - avatar