jeudi 12 novembre 2020

how do i amend or add an if statement to fix this script [closed]

i got the results i was looking for except the output for language "C" in my list comes out 1 characters long. how do i get just that one answer in the list to read "1 character long" while leaving the rest of them as is?

    languages = ['python', 'pearl', 'ruby', 'go', 'c']
    length = [len(language)for language in languages]
    for index, language in enumerate(languages):
        print("{} - {}, {} characters long".format(index+1, language, len(language)))

here is how the output of the script is printed:

1 - python, 6 characters long

2 - pearl, 5 characters long

3 - ruby, 4 characters long

4 - go, 2 characters long

5 - c, 1 characters long

Aucun commentaire:

Enregistrer un commentaire