-4
for char in "1bc4":
    print(char)

How can I modify this loop so it considers each character in turn: if it is a letter, it should print it converted to upper case; otherwise, it should print "not a letter". I.e. it should produce the output:

not a letter
B
C
not a letter

Please help, thanks!

bdeniker
  • 995
  • 1
  • 9
  • 21
Zara
  • 87
  • 7

1 Answers1

1

You need:

cha = "1bc4"
for c in cha:
    if c.isalpha():     
        print(c.upper())
    else:
        print("Not a letter")
Sociopath
  • 13,068
  • 19
  • 47
  • 75