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