I’m trying to get this code:
line = input("String: ")
letters = ""
words = line.split()
for word in words:
letters = letters + word[0]
print(" ".join(letters))
String = I have a dog
Result: I h a d
To print the result like this:
I h a d
Advertisement
Answer
change your print statement for this one
print("n".join(letters))
n is the new line character, that’s why.