jeudi 21 juin 2018

Python, scanning a string and spliting it

I am trying to learn how to program in Python 3, I did already a few courses but now I am stuck at a problem from a course example.

The goal is to: - program a code that will take a string as an input - go through the string and print (in a new line) in uppercase every word that starts with a letter that is >= "h" - Jump to the next word if the word starts with a G or lower letter

if someone has the time to take a look at this, I would be thankful

string = input ("input the string")
string = string.lower()
word = ""

for letter in string:

if letter.isalpha() == True:      

    if letter >= "h": 

        word += letter
        word.upper()


    else:
        word += ""           
        print("\n")

else:
    word += ""
    break`

Aucun commentaire:

Enregistrer un commentaire