I've got some simple python loop through a name to create a list of devices:
for i in range(18):
print("sfo-router",(i))
The problem is it prints with a space between the name and the number:
sforouter 1
sforouter 2
sforouter 3
sforouter 4
I'm just learning the ropes of python, so not sure how I can remove that space. How can it be done? thanks.
I'm new at python as well, and a quick google search did this one:
Just use
str.replace()
:Source: Python remove all whitespace in a string
Use format:
Change the
sep
parameter so thatprint
doesn't implicitly insert a space:Alternatively, you can convert your number to a string with
str
and concatenate:Outputs: (in both cases)