CS50P Plates code problem how to convert string to int
02:04 24 May 2026

Hi i am new to coding and i am attempting the Plates problem. I have an issue that when i try and convert text to an integer it remains as text. I dont really understand too much as i just started so any help is appreciated.

Plate = list(input("Enter your plate: ").strip())
for char in Plate:
    if char == ",":
        Plate.remove(char)

for char in Plate:
    if char == "1" or "2" or "3" or "4" or "5" or "6" or "7" or "8" or "9":
        char = char.replace(char,"_")

    else:
        char = char


print(Plate)


if Plate[0] == "_" or Plate[1] == ("_"):
    #Step2(Plate)
    print("Invalid")

elif Plate[0] != "_" and Plate[1] != "_":
    print("Good")


This is the output for inputing 1hello
Enter your plate: 1hello
['1', 'h', 'e', 'l', 'l', 'o']
Good

python loops cs50