Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Ashoka

  • 3 years ago

Hi, I am trying to print number in the loop but its saying invalid syntax for last for loop. Please debug it. packages = (6,9,20) n in range (56,66) T = [] i =0 for i in range(1,100): for x in range(1,100): for y in range(1,100): for z in range(1,100): if n== a*x+b*y+c*z: T.append(n) for len(T) >0: print T[i] i=i+1

  • This Question is Closed
  1. lopus
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    n in range(56,66) what is n ? what is a b c? not defined

  2. lopus
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    def diophantine1(): a=raw_input("write a: ") b=raw_input("write b: ") c=raw_input("write c: ") package=[a,b,c] for n in range(200,0,-1): cont=0 for i in range(0,10): for j in range(0,10): for k in range(0,10): p=((int(package[0]))*i)+((int(package[1]))*j)+((int(package[2]))*k) if p==n: cont+=1 if cont==0: print ("the largest number of McNuggets that cannot be bought in exact quantity is:" + str(n)) break

  3. Ashoka
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Hi lopus, Thanks for ur time! import this packages = (6,9,20) n in range (56,66) T = [] i =0 for i in range(1,100): for x in range(1,100): for y in range(1,100): for z in range(1,100): if n== packages[0]*x+packages[1]*y+packages[2]*z: T.append(n) #for len(T) >0: #print T[i] #i=i+1 for num in T: print num I want the combination of 3 numbers please explain the below line in your code for n in range(200,0,-1): And also i want to know if there is syntax error in below line for num in T: print num

  4. lopus
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    [200,199,198,197.....] (200,0,-1) start in 200 finish 0 decrees in -1

  5. lopus
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    man n is bad defined

  6. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy