dimanche 26 septembre 2021

How to be able to take more than 1 argument with loop?

I've been stuck on a function for my homework for hours. I've gotten the basic gist:to shorten the code. You have to print the first letter, "...", then the last letter. That part I got. But I can't figure out how to make it a loop to take more than 1 conditional arguments. Can anyone please help? It's supposed to be that if i type shorten_text("house","tree","major") it would print h...e, t...e, m...r on three seperate lines. Can anyone please help with the loop? Heres my code so far.

def shorten_text(word_list):
word_list[0]+"..."+word_list[-1]
print(word_list[0]+"..."+word_list[-1])
if word_list == "":
    print("Input is empty")



Aucun commentaire:

Enregistrer un commentaire