How to eliminate spacing due to Python print ','

Asked 2 years ago, Updated 2 years ago, 115 views

a = input()
print(a[:2],"sh"
print(a[3:]"Minutes")

It comes out like this because I used and but how do I print out without spacing?

(I want to minimize the running time!))

python print format-string

2022-09-20 15:41

2 Answers

https://docs.python.org/ko/3/tutorial/inputoutput.html

>>> a = input()
07:10
>>> print(a[:2],"si")
07 si
>>> print(f"{a[:2]}si")
07si
>>> print("%ssi"%(a[:2]))
07si
>>> print("{0}si".format(a[:2]))
07si


2022-09-20 15:41

The print function supports the sep factor, and the default is '.

If you have a print('1', '2') code, try print('1', '2', step=').


2022-09-20 15:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.