+ 2

Python

How to make a list of combination of all the numbers from 1 to 128 keeping ' '. The output will be- '1,2','1,3','1,4'........

21st Sep 2021, 10:17 AM
Sourya Banerjee
Sourya Banerjee - avatar
3 Answers
+ 2
Please, firstly show your attempt. After that ask what your problem is clearly. Thanks for understanding. Happy coding!
21st Sep 2021, 10:41 AM
mesarthim
mesarthim - avatar
+ 2
Sourya Banerjee , if you are allowed to use python library itertools you can use permutations. [edited]: as you have required the output as string, we can do it also with 2 nested for loops. the output is a list containing strings with the numbers: ['1,2', '1,3', '1,4', '1,5', '1,6', '1,7', '1,8', '1,9', '2,1', '2,3', '2,4', '2,5', '2,6', '2,7', '2,8', '2,9', '3,1', '3,2', '3,4', ...]
21st Sep 2021, 2:14 PM
Lothar
Lothar - avatar
+ 1
What should be the last output number ?
21st Sep 2021, 11:38 AM
Angela
Angela - avatar