jak10101
jak10101

Reputation: 19

python 2.7.6 printing strings vertically while using loops

I am writing a code that needs to print a string vertically. How do i do this? Someone in my class told me to try this:

string = raw_input ('Please enter a string. ')
    while string() true:
        print string().

I tried this and it didn't work. Any ideas?

Upvotes: 0

Views: 1397

Answers (1)

Maxime Lorant
Maxime Lorant

Reputation: 36161

If you want to print each character of a string on a new line, you can iterate over the string:

user_input = raw_input ('Please enter a string. ')  # store the string if a variable 
for c in user_input:        # for each character 'c' in the input
     print(c)               # print it. The print function add a new line character at each call

Upvotes: 2

Related Questions