Re: [Tutor] Question about loop and assigning variables

2017-04-06 Thread Mats Wichmann
On 04/05/2017 01:07 PM, Fazal Khan wrote: > Hello, > > Heres another newbie python question: How can I loop through some data and > assign different variables with each loop > > So this is my original code: > > def BeamInfo(x): > for Bnum in x: > if

Re: [Tutor] Question about loop and assigning variables

2017-04-05 Thread Steven D'Aprano
On Wed, Apr 05, 2017 at 12:07:05PM -0700, Fazal Khan wrote: > Hello, > > Heres another newbie python question: How can I loop through some data and > assign different variables with each loop You don't. That's a bad idea. Instead, you use a sequence (a tuple, or a list), and use an index:

Re: [Tutor] Question about loop and assigning variables

2017-04-05 Thread Alan Gauld via Tutor
On 05/04/17 20:07, Fazal Khan wrote: > assign different variables with each loop You can't, but you can fake it... > def BeamInfo(x): > for Bnum in x: > if plan1.IonBeamSequence[Bnum].ScanMode == 'MODULATED': > TxTableAngle = >

[Tutor] Question about loop and assigning variables

2017-04-05 Thread Fazal Khan
Hello, Heres another newbie python question: How can I loop through some data and assign different variables with each loop So this is my original code: def BeamInfo(x): for Bnum in x: if plan1.IonBeamSequence[Bnum].ScanMode == 'MODULATED': TxTableAngle =