vendredi 5 février 2021

if list contains variable change it to item once

d = input("fill in:")
d = d.lower()
y = ['a', 'b', 'c']
if d in y:
  for x in y:
    d = d.replace(x, "d")
    print(d)
else:
  print("false")

If the user fills in a, b, or c it is supposed to print out d, if not a,b,c it is supposed to say "false". In this case the program returns 3 times, how do I fix this?

Aucun commentaire:

Enregistrer un commentaire