468,268 Members | 1,753 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

doubling a string by using 'for' loop

I want to double a string by using 'for' loop in a special way for example:
Expand|Select|Wrap|Line Numbers
  1.  
  2. string1 = 'abc'
  3. #after doubled
  4. string1 = 'aabbcc'
  5.  
anyway, in python what does "+=" mean?
Sep 24 '07 #1
1 1545
ghostdog74
511 Expert 256MB
I want to double a string by using 'for' loop in a special way for example:
Expand|Select|Wrap|Line Numbers
  1.  
  2. string1 = 'abc'
  3. #after doubled
  4. string1 = 'aabbcc'
  5.  
anyway, in python what does "+=" mean?
Expand|Select|Wrap|Line Numbers
  1. >>> s="abc"
  2. >>> ''.join([i*2 for i in s ])
  3. 'aabbcc'
  4.  
c+=1 means the same as c=c+1
Sep 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

12 posts views Thread by Kamilche | last post: by
17 posts views Thread by Chad Myers | last post: by
17 posts views Thread by Jonathan Pritchard | last post: by
2 posts views Thread by Blasting Cap | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.