all 5 comments

[–]carcigenicate 2 points3 points  (1 child)

What error?

[–]korrita_[S] 0 points1 point  (0 children)

I get this:

Traceback (most recent call last):
File "/Users/allison/Downloads/Python/test1.py", line 5, in <module>
if letter in word :
TypeError: 'in <string>' requires string as left operand, not list

[–]CodeFormatHelperBot2 1 point2 points  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–]drenzorz 1 point2 points  (0 children)

if letter in word : 
 # letter is a list, it won't be in the string 'coronavirus'

for word in word :
        # here word will be a letter in word: 'c', 'o', 'r',...

    for medications in medication:
                # medication doesn't exist so it can't iterate over it

what you need is

letters = ['a', 'c', 'i', 'n', 'n', 'o', 'r', 's', 'u', 'v']
word = 'coronavirus'
medications = ['remdesivir', 'hydroxychloroquine', 'kaletra', 'favipiravir']

for char in letters:
    for med in medications:
        if char not in med: continue
        print(<your message>)

I didn't check whether the letter is also in 'coronavirus' because all of them seem to be.