samedi 28 septembre 2019

I was trying to check if an input is equal to a character in a string

I tried to find out if an input is a part of the string

if my_input==astring[i]:

However, python returns me with an error:

Traceback (most recent call last):
  File "/home/user/Desktop/Programs/test.py", line 7, in <module>
    if my_input==astring[i]:
builtins.TypeError: string indices must be integers

How should I fix this?

Aucun commentaire:

Enregistrer un commentaire