0

Is this codeing correct?

from random import shuffle from math import factorial as fact try: nums = [int(x) for x in input().split()] or [1,2,3,4,5] if len(set(nums)) < 3: raise ValueError except ValueError: print("Please enter at least 3 unique numbers.") print('Example: "1 2 3 4 5"') quit() else: print("Input:", *nums) print("\nOutput:") arr = set() while len(arr) < fact(len(nums)): arr.add(tuple(nums[:])) shuffle(nums) for x in sorted(list(arr)): for y in range(len(x)-2): if x[y] > x[y+1] > x[y+2] or x[y] < x[y+1] < x[y+2]: break else: print(x)

28th Sep 2023, 6:32 AM
Shivam
3 Antworten
+ 6
Shivam , the code is running well, but this does not mean that it is working as expected. > please give a task description so that we get an idea of what the code is going to achieve. > also add the programming language in the tags, not as a separate information
28th Sep 2023, 10:24 AM
Lothar
Lothar - avatar
+ 1
Why not try it in playground? Or IDLE if you installed Python on your computer?
28th Sep 2023, 10:23 AM
Wong Hei Ming
Wong Hei Ming - avatar
0
This is python
28th Sep 2023, 6:33 AM
Shivam