Prepending string "@" to usernames

Discussion in 'Python' started by Thomas Murphy, May 24, 2013.

  1. 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
     
    Thomas Murphy, May 24, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Stromberg

    Re: Prepending string "@" to usernames

    Dan Stromberg, May 25, 2013, in forum: Python
    Replies:
    0
    Views:
    92
    Dan Stromberg
    May 25, 2013
  2. Thomas Murphy

    Re: Prepending string "@" to usernames

    Thomas Murphy, May 25, 2013, in forum: Python
    Replies:
    0
    Views:
    78
    Thomas Murphy
    May 25, 2013
  3. Andrew Berg

    Re: Prepending string "@" to usernames

    Andrew Berg, May 25, 2013, in forum: Python
    Replies:
    0
    Views:
    98
    Andrew Berg
    May 25, 2013
  4. Mark Lawrence

    Re: Prepending string "@" to usernames

    Mark Lawrence, May 25, 2013, in forum: Python
    Replies:
    0
    Views:
    98
    Mark Lawrence
    May 25, 2013
  5. Tim Chase
    Replies:
    0
    Views:
    76
    Tim Chase
    May 25, 2013
Loading...

Share This Page