User Profile

Collapse

Profile Sidebar

Collapse
James Carpenter
James Carpenter
Last Activity: Mar 2 '12, 01:20 AM
Joined: Feb 13 '12
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Python 2.7.2+ (Oct 4 2011)
    Ubuntu 11.10 (unity removed, using Gnome Classic)
    gedit
    See more | Go to post

    Leave a comment:


  • James Carpenter
    started a topic Adding elements of list into a string

    Adding elements of list into a string

    Good day,

    I am trying to use a list of integers and strings, take certain elements out, and concatenate them into a string.
    i.e.
    Code:
    lista = [0,'f',0,1,1,1,0,'a',8]
    split_length = 3
    stringa = ''
    
    while split_length >= 0:[INDENT]print 'XX ',[/INDENT][INDENT]for idx in lista:[/INDENT][INDENT][INDENT]stringa = stringa + str(lista[idx]) + ' ',[/INDENT][/INDENT][INDENT]print 'XX'[/INDENT]
    What I am wanting this to print would be:
    XX 0 f 0 XX
    ...
    See more | Go to post

  • James Carpenter
    replied to list / index
    Ohh, wow, much more simple, thanks!
    See more | Go to post

    Leave a comment:


  • James Carpenter
    started a topic list / index

    list / index

    let's say I have a list
    list1 = [0,0,0,0,0,0,1,0 ,0,0,0,0,1,1,1, 0,0,0,1,0]
    now I have another list
    list2 = [5,9,10]

    What I am trying to do is check the value of each index in list2, for that index in list1

    i.e.
    list2, index(0), is 5, I want to check the value of the index(5) in list1

    I was thinking a for loop with an if loop inside it, but I'm not sure how to call the corresponding...
    See more | Go to post
No activity results to display
Show More
Working...