I'm trying to find a letter in a giving string. Here's what I got:
if i in steps == 'u':
y -= pixels_per_move
elif i in [steps] == 'r':
x -= pixels_per_move
steps is a randomly generated string consisting of u, d, r, l. So it's something like 'uuurlluddd'
So i'm just looking for those letters in 'steps' but with the code above I'm getting the error
TypeError: 'in ' requires string as left operand, not int
Which I don't understand because steps is not an int, and i've tried putting str() around it in multiple places but same error occurs. What am I doing wrong here?
Aucun commentaire:
Enregistrer un commentaire