Home Why am I getting an infinite loop from this while inside a for?
Reply: 1

Why am I getting an infinite loop from this while inside a for?

Stack Johan
1#
Stack Johan Published in 2018-01-11 06:57:50Z

I'm enumerating rawdata and adding values to dedque dex

   for index, track in enumerate(rawdata):
        while index < 49:
            dex.append(track[0])
Mohamed Daaniyaal
2#
Mohamed Daaniyaal Reply to 2018-01-11 07:19:30Z

The value of index is not changing inside the while loop. i.e, index is not been incremented.

while index > 49 : is always true. Hence try incrementing the index value inside the while loop to exit out of the while loop and proceed to the next iteration of the outer for loop.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313187 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO