Python lines in one word


#1

How to return this in one line? For example:
how to return ABCD instead of:
A
B
C
D


#2

Hi @zutko123 ,

Put a comma at the very end of your print statement to suppress a line feed.


#3

Thank you that works for print but i must return and that doesen't work


#4


#5

Regarding your original question and your first reply, try this example; see if it helps ...

letters = ["P", "y", "t", "h", "o", "n"]
for ch in letters:
    print ch, # output with no line feed
print # add a line feed
print "Done!" # announce that we are done

#6

Thank you! :slight_smile:


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.