(Answered) Please tell me why my code is printing vertically instead of horizontally. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 1

(Answered) Please tell me why my code is printing vertically instead of horizontally.

7th Sep 2020, 6:35 AM
Hyperion
Hyperion - avatar
6 Respostas
+ 9
x = input().split() is all you need for the first line (try it šŸ˜Š). split() generates a list by itself, so you don't need a list comprehension. Also, input() always generates a string, so you don't need str().
8th Sep 2020, 1:52 AM
David Ashton
David Ashton - avatar
+ 2
Check if your code has a new line character after every character/string/number in your print function
7th Sep 2020, 8:36 AM
Kkristina
Kkristina - avatar
+ 2
and end=" " in print, because default is end="\n" print(new_word + first_letter + "ay", end = " ")
7th Sep 2020, 9:22 AM
Jayakrishna šŸ‡®šŸ‡³
+ 2
Thanks
8th Sep 2020, 4:12 AM
Hyperion
Hyperion - avatar
+ 1
x = [str(x) for x in input().split()] for words in x: first_letter = words[0] new_word = words[1:] print(new_word + first_letter + "ay")
7th Sep 2020, 8:58 AM
Hyperion
Hyperion - avatar
+ 1
Thanks
7th Sep 2020, 9:54 AM
Hyperion
Hyperion - avatar