Jump to content

you can't do

for x, y in (1,2):    //do stuff

but you can do

x, y = (1,2)

Pro Tip: don't use flash when taking pictures of your build; use a longer exposure instead. Prop up your camera with something (preferably a tripod) if necessary.

if you use retarded/autistic/etc to mean stupid please gtfo

Link to comment
https://linustechtips.com/topic/473601-loop-help-python/#findComment-6346894
Share on other sites

Link to post
Share on other sites

Why don't you just write

for y in x:   print y

as the second loop? also, I don't think (1,2) is a recognizable form, but I could be wrong.

it's a tuple.

Pro Tip: don't use flash when taking pictures of your build; use a longer exposure instead. Prop up your camera with something (preferably a tripod) if necessary.

if you use retarded/autistic/etc to mean stupid please gtfo

Link to comment
https://linustechtips.com/topic/473601-loop-help-python/#findComment-6346896
Share on other sites

Link to post
Share on other sites

What are you trying to do here?

Well in this project that I have to do, those are coordinates, and I have to take those coordinates and enter them into another function. That's why I want both variables there like I had it. In the real function, the list is much longer.

Link to comment
https://linustechtips.com/topic/473601-loop-help-python/#findComment-6347033
Share on other sites

Link to post
Share on other sites

Well in this project that I have to do, those are coordinates, and I have to take those coordinates and enter them into another function. That's why I want both variables there like I had it. In the real function, the list is much longer.

I don't understand from the way you typed it can you maybe write it in Pseudo Code or a flowchart so I can help?

Have 3yrs of Python knowledge from School and am happy to assist

Link to comment
https://linustechtips.com/topic/473601-loop-help-python/#findComment-6349059
Share on other sites

Link to post
Share on other sites

I don't understand from the way you typed it can you maybe write it in Pseudo Code or a flowchart so I can help?

Have 3yrs of Python knowledge from School and am happy to assist

Sure sure. So I basically want to pull these numbers out of the list as coordinates (x, y) because I need to pass them through another function which takes two parameters, x and y. That's why I want to pull them out two at a time.聽

So if we have a list of tuples:

list = [(2,1), (1,2)]

cycle though list: 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽聽

聽 聽 cycle through tuple setting each number equal to x and y respectively: 聽 聽 聽#so in this case, x and y would be 2 and 1 for the list's first member and 1 and 2 for the second

聽 聽 聽 聽 function(x, y)

I hope that I explained that okay. Thanks so much for your help.

Link to comment
https://linustechtips.com/topic/473601-loop-help-python/#findComment-6349963
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now