supervirus
supervirus

Reputation: 97

Python concatenate a string and a variable

I am trying to concatenate strings and variables , i see new lines get added ..

def convert_hostname(row_rack,ru_host,orig_hostname):
  if orig_hostname[0:9] == "ll21l01ms":
     print row_rack,
     print ru_host,
     temp_var = "ll21l01ls-" + row_rack + ru_host + ".com"
     print temp_var

Output when run :
0707
49
ll21l01ls-0707
49
.com

When i try to print the temp_var , it adds new lines during the concatenation.

The with output should be like this :

0707
49
ll21l01ls-070749.com

Any ideas?

Upvotes: 3

Views: 17762

Answers (1)

Cyb3rFly3r
Cyb3rFly3r

Reputation: 1341

Try:

temp_var = "ll21l01ls-" + row_rack.strip() + ru_host.strip() + ".com"

Upvotes: 4

Related Questions