Problem when using the function .join ()

0

What's the problem with my code, I used the .split () function to separate the string when it finds'; ', after separating I wanted to join to come back putting spaces so I used the .join (), however I did not see effects see:

#Irá separar cada palavra quando encontrar o delimitador ';'

reg = str(input('Nome; endereço; telefone: '))

nome, endereco, telefone = reg.split(';')
print('{}  {}  {} '.format(nome, endereco, telefone))

' '.join(reg)
print(reg)

'''
Tentei fazer dessa forma também:

' '.join(nome, endereco, telefone)
print(reg)

n deu.
'''

    
asked by anonymous 03.08.2017 / 06:26

1 answer

2

Join does what you want, but in a list:

' '.join(['nome', 'endereco', 'telefone'])
'nome endereco telefone'

But if you, in the example, just want to remove the point and a point from the original string, use replace, see example:

reg = 'Carlos; Av. Marechal, 3; 392-323'
reg = reg.replace(';','')

print(reg)
Carlos Av. Marechal, 3 392-323
    
03.08.2017 / 06:42