Reputation: 7
I'm looking for a solution for this, searched and tried several ones, but none working with int datatypes, using python 3.8.5.
begin = 1
end = 273
print ("lines:", begin, "-", end)
result:
lines: 1 - 273
needed:
lines: 1-273
What do I need to do to remove the blank spaces using string and integer variables?
Thx
Upvotes: 0
Views: 1089
Reputation: 21
Instead of using ,
you can use +
begin = 1
end = 273
print ("lines:", str(begin)+"-"+str(chunk1_end))
or you can use str.format()
begin = 1
end = 273
print ("lines: {}-{}".format(begin, chunk1_end))
Upvotes: 1
Reputation: 31
You can use f strings, introduced in python 3.6.
begin = 1
end = 273
print(f"lines: {begin}-{end}")
Upvotes: 3
Reputation: 21
try this line it's better
print(f"lines: {begin}-{chunk1_end}")
also makes your code readable and more controllable
Upvotes: 2