0

I have two lists:

ask[]
timeStamp[]

I need to add the information in these lists into a two dimensional array.

Here is my code:

for item in actTime:
    rawData.append(ask[x],timeStamp[x])
    x = x + 1
5
  • 2
    What is actTime supposed to be? Commented Mar 23, 2012 at 3:09
  • possible duplicate of Python values of multiple lists in one list comprehension Commented Mar 23, 2012 at 3:10
  • Someone find a better duplicate about zip. Commented Mar 23, 2012 at 3:11
  • the timeStamp list in the loop should actually be the actTime list. But regardless its just a list containing a time Commented Mar 23, 2012 at 3:14
  • 1
    Be precise. Show us an example of the contents of the lists before you start, and what you want the corresponding result to be. Commented Mar 23, 2012 at 3:23

1 Answer 1

4

Use zip:

>>> pairs = zip(ask, timeStamp)

This will return a list of (tuple) pairs.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.