How do I stop end="" after all the integers have been combined?

45 Views Asked by At

I want end="" to stop after it has removed all the spaces between integers.

The result I get is this:

106111104110word

but I want to get this:

106111104110
word

Code:

name = 'john' 

for char in name:
    print(ord(char), end="")
print("word")
4

There are 4 best solutions below

0
Dodo On BEST ANSWER

store your answer in a variable, and then print. Other answers in this thread work too, but this way you can also use the result.

name = 'john' 
result = ""

for char in name:
    result += str(ord(char))

print(result)
print("word")
0
Khaled DELLAL On

Add \n in your code:

name = 'john' 

for char in name:
    print(ord(char), end="")
print("\nword")
0
Ben Grossmann On

You could do this:

name = 'john' 

for char in name:
    print(ord(char), end="")
print()
print("word")
1
Derek Strange On

name = 'john' result = ""

for char in name: result += str(ord(char))

print(result) `println() print("word")

or you can use /n :

  • List item

')