0

Hi please can someone explain why the underscore in this code fails to show when printed. Thank you.

names = ["Joey Tribbiani", "Monica Geller", "Chandler Bing", "Phoebe Buffay"]
usernames = []
for name in names:
    name.lower().replace(" ", "_")
    usernames.append(name)

print(usernames)

Output

['Joey Tribbiani', 'Monica Geller', 'Chandler Bing', 'Phoebe Buffay']

Sandrin Joy
  • 1,120
  • 10
  • 28
Chinedu
  • 27
  • 2

1 Answers1

1

It was because you were not assigning the processed data to variable name.

names = ["Joey Tribbiani", "Monica Geller", "Chandler Bing", "Phoebe Buffay"]
usernames = []
for name in names:
    name=name.lower().replace(" ", "_")
    usernames.append(name)

print(usernames)
Sandrin Joy
  • 1,120
  • 10
  • 28