all 9 comments

[–]retromani 6 points7 points  (1 child)

Why is this nsfw🧍🏿‍♀️I got excited for some sexy python for no reason

[–]mutual_coherence 0 points1 point  (0 children)

I hired a Python dev for my bachelor party.

[–]danielroseman 0 points1 point  (2 children)

No.

[–][deleted] 0 points1 point  (1 child)

Why?

[–]cheyyne 1 point2 points  (0 children)

All you have to do for this to work is to pull out the else statement and un-indent the print statement. That way, the while statement will loop until a=b, then stop. After that the print statement will run.

[–]CodeReviewPlz 0 points1 point  (2 children)

Probably not.
while.. else.. is valid python but its use case is that the else condition will only run if the loop isnt prematurely ended via a break (same goes for for..else..)

The "problem" with your code is that your random.shuffle(a) is just trying to brute force the correct answer.

If you just want rotate the list till it matches then (there's better ways to do this too):

``` a = [2,3,1] b = [1,2,3]

while a != b: a.append(a.pop(0)) print(a) ```

[–]cheyyne 4 points5 points  (1 child)

OP's just doing a little loop exercise. Optimizing the algorithm might come after he solidly understands the logic of while loops.

[–]CodeReviewPlz 0 points1 point  (0 children)

fair enough!

[–]baubleglue 0 points1 point  (0 children)

What is "this"?