Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #45923 > unrolled thread

Re: Prepending string "@" to usernames

Started byDan Stromberg <drsalists@gmail.com>
First post2013-05-24 16:00 -0700
Last post2013-05-24 16:00 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Prepending string "@" to usernames Dan Stromberg <drsalists@gmail.com> - 2013-05-24 16:00 -0700

#45923 — Re: Prepending string "@" to usernames

FromDan Stromberg <drsalists@gmail.com>
Date2013-05-24 16:00 -0700
SubjectRe: Prepending string "@" to usernames
Message-ID<mailman.2082.1369436425.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

On Fri, May 24, 2013 at 3:53 PM, Thomas Murphy
<thomasmurphymusic@gmail.com>wrote:

> 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
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Maybe this is what you're looking for?

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

final_address = []
for address in address_library:
    final_address.append("@" + str(address))
print final_address

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web