Prepending string "@" to usernames

Thomas Murphy thomasmurphymusic at gmail.com
Fri May 24 18:53:52 EDT 2013


Hi beloved list,

I'm having a dumb and SO doesn't seem to have this one answered. I was
sent a long list of instagram usernames to tag for a nightlife
announcement in this format(not real names(i hope))

cookielover93
TheGermanHatesSaurkraut
WhatsThatBoy932834

I'd like to turn this raw text into a list and prepend the @ symbol to
the front of each one, so they're good to go for pasting without me
having to manually add the @ to each one.

Here's where I got to:


raw_address = "cookielover93 TheGermanHatesSaurkraut WhatsThatBoy932834"
address_library = [raw_address.split()]
print address_library

for address in address_library:
    final_address = "@" + str(address)
print final_address


However my output is:

[['cookielover93', 'TheGermanHatesSaurkraut', 'WhatsThatBoy932834']]
@['cookielover93', 'TheGermanHatesSaurkraut', 'WhatsThatBoy932834']


I know I'm iterating wrong. May I ask how?

--
Sincerely,
Thomas Murphy
Code Ninja
646.957.6115



More information about the Python-list mailing list