Need help on a partition function in Python (example: 3 = 1+1+1 and 1+2)

I’m trying to make a function that finds all the partitions in a number. I got an idea to put in a for loop on the same line as the while loop, but I’m not sure if I’m formatting it correctly or it’s just not possible. Any hints on the partition function or the for loop on the while loop are helpful

x = 0 while x <= for i in some_list: # Does Something x += 1

I understand what you’re going for but the syntax here should probably be two separate loops nested in the normal way. There may be routes to remove a loop by carefully selecting what you iterate through but I’d suggest saving that for a refactor if it’s not something immediately obvious to you.

Since it’s a challenge I’d not want to provide much else but one of the standard routes is to consider how you’d solve this yourself, e.g. with pen and paper. If you can work out what steps your logic requires then it’s easier to translate that into code.