Python Forum
Loop does not work in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loop does not work in python
#4
Yes indeed. The function will always return "2". Look sharp at your code:
    even2="2"
    ...
    clusterAssigments=even2
    return clusterAssigments
You should write comment lines (starting with "#") in your code for explanation, because I cannot understand what you are trying to achieve. But I can see there are problems with the following part:
    while ref==even1:
        clusterAssigments=even2
        if ref==uneven1:
            clusterAssigments=uneven1
        else:ref==even1 and ref==uneven3
In the while you compare an integer (ref) with a bool (even1). I checked it by placing print statements before the while loop.
    print("ref=" + str(ref))
    print("even1=" + str(even1))
Output:
ref=10 even1=True
So I can tell you: the loop will not execute. And if it would execute, how would it end? The line else:ref==even1 and ref==uneven3 is of course also not correct. You execute a boolean expression and do not assign it to anything.
I hope this helps you.
Reply


Messages In This Thread
Loop does not work in python - by Ola92 - Jan-12-2020, 10:12 AM
RE: Loop does not work in python - by Larz60+ - Jan-12-2020, 03:14 PM
RE: Loop does not work in python - by Ola92 - Jan-12-2020, 06:22 PM
RE: Loop does not work in python - by ibreeden - Jan-12-2020, 07:34 PM
RE: Loop does not work in python - by Ola92 - Jan-12-2020, 07:42 PM
RE: Loop does not work in python - by Ola92 - Jan-12-2020, 08:50 PM
RE: Loop does not work in python - by sandeep_ganga - Jan-13-2020, 05:43 AM
RE: Loop does not work in python - by Ola92 - Jan-13-2020, 10:18 AM
RE: Loop does not work in python - by sandeep_ganga - Jan-13-2020, 10:41 AM
RE: Loop does not work in python - by Ola92 - Jan-13-2020, 12:20 PM
RE: Loop does not work in python - by sandeep_ganga - Jan-13-2020, 03:43 PM
RE: Loop does not work in python - by Ola92 - Jan-13-2020, 06:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Issues with while loop, while (var != 0): does not work, but while (var !=''): works danilo 2 2,117 Apr-15-2019, 12:08 AM
Last Post: danilo
  Hi, my loop yes/no part doesn't work and I really need help fordxman5 2 2,668 Feb-14-2018, 11:38 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020