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. Advertisements

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. =?Utf-8?B?Sm9l?=

    IIS6 not logging Authenticated Usernames

    =?Utf-8?B?Sm9l?=, Sep 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    676
    Bruce Barker
    Sep 16, 2005
  2. Ahmed Moustafa
    Replies:
    5
    Views:
    616
    Brian Palmer
    Aug 20, 2003
  3. Aaron Whiffin
    Replies:
    0
    Views:
    831
    Aaron Whiffin
    Sep 4, 2003
  4. Titus A Ducksass
    Replies:
    3
    Views:
    585
    brucie
    Dec 25, 2003
  5. Replies:
    1
    Views:
    439
  6. Stefan Behnel

    Prepending to traceback

    Stefan Behnel, Feb 2, 2005, in forum: Python
    Replies:
    3
    Views:
    421
    Ian Bicking
    Feb 9, 2005
  7. Serdar Kýlýç

    Array prepending nil object

    Serdar Kýlýç, Jan 31, 2006, in forum: Ruby
    Replies:
    3
    Views:
    193
    Serdar Kýlýç
    Jan 31, 2006
  8. Dave

    Prepending to a file

    Dave, Jul 24, 2005, in forum: Perl Misc
    Replies:
    2
    Views:
    201
Loading...