+ 1
How to join lines?
Hello, making a game to help kids learn English. How do I get lines to join? For example, right now (if you run this code) you'll see that "named" and "input" and "Who lived" are on three separate lines? How do I get them to all output on one line? Thanks. UNI = input("Welcome ") print(UNI) print("Dragon or Unicorn?") Drag_or_Uni = input("\nSo you chose ") print(Drag_or_Uni) print("Once upon a time there was a young unicorn named ") print(UNI) print("Who lived in a magical forest. This world is yours to explore and themore answers you get correct the more powers you will have. Let's begin.....")
5 Respuestas
+ 5
Various methods to get output on the same line:
name = 'tristach605'
print('Your name is', name)
print('Your name is ' + name)
print('Your name is {}'.format(name))
print('Your name is %s' % (name,))
print(f'Your name is {name}')
print('Your name is ', end='')
print(name)
+ 4
Or you can do:
print("\n".join(list_of_lines))
Or just using print:
print(*list_containing_lines, sep="\n")
+ 3
You can do it like this:
print('Once upon a time '
'there was this thing '
'I call auto concat.')
In output this will be just one line.
For more details:
https://code.sololearn.com/c9a0cG9dpVUr/?ref=app
+ 1
Thanjs HF and Pro!
0
Sorry? Where does it go exactly? cannot get it to work. Im trying to join between "named" "print(UNI)" and
UNI = input("Welcome ")
print(UNI)
print("Dragon or Unicorn?")
Drag_or_Uni = input("\nSo you chose ")
print(Drag_or_Uni)
print("Once upon a time there was a young unicorn named ")
print(UNI)
print(("Who lived in a magical forest. This world is yours to explore and the more answers you get correct the more powers you will have. Let's begin....."))
#Or you can do:
#print("\n".join(list_of_lines))
#Or just using print:
#print(*list_containing_lines, sep="\n")