0

I was trying to learn some basic python, and I didn't succeed to find a good way to express a1,a2,a3... in a loop

while a3<=a4:
    if a3==b3:
        a3=a3-a2+a1+250
    else:
        print (a3)
        a3=a3+250
if a3>a4:
    a3=a3-250 
while a5<=a6:
    if a5==b5:
    a5=a5+250-a4+a3
    else:
        print (a5)
        a5=a5+250
if a5>a6:
    a5=a5-250

while a7<=a8:
    if a7==b7:
        a7=a7+250-a6+a5
    else:
        print (a7)
        a7=a7+250
if a7>a7:
    a7=a7-250
jqin
  • 23
  • 3
  • 2
    You could use an [array](https://stackoverflow.com/questions/1514553/how-to-declare-an-array-in-python) – litelite Aug 14 '17 at 13:13
  • Why do you even have a 100 variables? Wouldn't a list of length 100 be more convenient? Then you can say while a[i]<=a[i+1]: … etc – Simon Klaver Aug 14 '17 at 13:14
  • 1
    hm. sorry, but i hardly understand what you are trying to achieve – DonGru Aug 14 '17 at 13:15
  • I am feeling the same as @DonGru and Btw `if a7>a7:a7=a7 - 250` will never execute... You can throw it away, unless it was a typo?... – officialaimm Aug 14 '17 at 13:16
  • 1
    Simply do not use 100 variables, but a list `a = [ None, a1, a2, a3, a4, ...,a100 ]`. Then `for i in range(3, 100): while a[i] <=a[i+1] ...` – Serge Ballesta Aug 14 '17 at 13:16
  • @officialaimm yes it was a typo – jqin Aug 14 '17 at 14:26
  • @DonGru sorry it was part of a code, the intend is input multiple durations of frames, like a1-a2, a3-a4 and cut them every 250 frames and export the frame that was cut – jqin Aug 14 '17 at 14:27

1 Answers1

2

I agree with @DonGru

sorry, but i hardly understand what you are trying to achieve

However I think that an array and a while loop would help. something like:

arr = [a1,a2,a3,a4]
i = 0
while i <= 3:
    #math code you want to do using arr[i] instead of a1,a2,etc.
    i += 1