mercredi 28 juillet 2021

How would you check if a letter/number/symbol is in a string? (Python)

Sorry for asking a fairly simple question, but how would I make it so that if a certain letter/symbol/number would "activate" an if statement when the letter (for example "a") is in the element. If I make

thestring = ["a"]

(And then add the if statement ^^) Then it would work but if I add another letter or number next to it:

thestring = ["ab"]

(And then add the if statement ^^) It wouldn't work anymore. So essentially, how can I fix this?

Sample Code:

thestring = ["fvrbgea"]

if "a" in thestring:
  print("True")
Output: (Nothing here since there's not an else code I guess.)

Aucun commentaire:

Enregistrer un commentaire