2

I have array: a = [1,2,3,4]

yellow = a[0]
 red= a[1]
 blue = a[2]
 green = a[3]

Want to assign variables of each value of array in one line.

0

1 Answer 1

7

If the number of elements match the number of variables you can use:

yellow, red, blue, green = a

If not, you can use:

yellow, red, blue, green = a[0], a[1], a[2], a[3]
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.