The program took too long to run. Check for infinite loops


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/3/1?curriculum_id=4f89dab3d788890003000096


The program took too long to run. Check for infinite loops. My code provides the expected results and exits with code=0 in 0.245 seconds. Is there a better way?


n = [3, 5, 7]

for i in range(0, len(n)):
    print n[i]
    
def print_list(x):
    while i<=n:
        print n


#2

Your function will either do nothing or never terminate


#3

Ahh. The result was coming from my for statement not my function. I was confused because I thought the results were coming from my function. Thank you!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.