syntax error <string> workaround

Asked 2 years ago, Updated 2 years ago, 16 views

keywords_in_abstract = []

for ab in downloaded_abstracts:

        keyword_box = []

        words = ab.replace('.','').split(' ')

        for w in words: 
                if w.upper() = disease:    
                        keyword_box.append(w.upper())

        for w in words:
                if w.upper() = disease:
                        keyword_box.append(w.upper())

I typed it like this.

    if w.upper() = disease:
Syntax Error: invalid syntax: <string>, line 56, pos 30

I got this error... Why is it coming up? <

python

2022-09-20 15:59

1 Answers

>>> s = "aBc"
>>> if s.upper() = "ABC":

SyntaxError: invalid syntax



>>> if s.upper() == "ABC":
    print(f"{s} equals `ABC`")


aBc equals `ABC`


2022-09-20 15:59

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.