+ 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()
9 Respuestas
+ 1
Something like this?
https://code.sololearn.com/cC2jUWBUi1Tg/?ref=app
+ 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.
+ 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.
+ 2
Thanks notqueued !
+ 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.
+ 1
David Ashton is this the proper way to use this with multiple lists? https://code.sololearn.com/cQuMBp6mYe0d/?ref=app
+ 1
Cameron Welker That's exactly right. I wrote this code recently using the same principles
https://code.sololearn.com/cbV3CNmUih0C/?ref=app
+ 1
David Ashton Thank you for all the help! :)
+ 1
Cameron Welker You're welcome! 😊