Reverse lists and group
How can I group the reverse list of integers? The output should be grouped on reverse. Example: Input: 5 2 3 1 8 6 My desired Output: [6,8]--[3,2] I don't know the basis of how this group came to be. The assignment only says to "group them according to your liking with proper code" This is my code: https://code.sololearn.com/cA25a9a14A38
6/16/2021 1:37:53 PMBrianna
10 AnswersNew Answer
Seems to give your desired output. https://code.sololearn.com/c7J39S3Fb0ph/?ref=app Input: (size of array) 5 (then elements of array) 2 3 1 8 6 Output: [6,8]--[3,2] I just played around with indices a bit (Not the best solution I guess 😅). Do ask if you have any doubts.
For this question complete the course bit more.As you have completed 13% of it only
Nivya he is expecting this output, I think [6,8] [1,3] [2,5]
Yea Atul may be or anything based on the conditions ,until he gives what it is actually we cant help out!
Emma Thank you so much! But what about if the array size is 7?
Brianna Code will give output, since I wrapped it in try-catch. But from your example I guess I understood it wrong. I thought the task was to group first two consecutive numbers and then group the third number and continue like that.. But then I saw this question. https://www.sololearn.com/Discuss/2814208/?ref=app and maybe the answers in the above questions is your desired output? https://code.sololearn.com/cfhTguBgkUOh/?ref=app [Edit] Brianna, You can modify 🅰🅹 🅐🅝🅐🅝🅣 code with commas according to your wish :) https://code.sololearn.com/c6Ao4n1G2MX9/?ref=app
Emma ,The recent code that you gave is actually right, the only problem is that it didn't have a comma between the numbers. (I saw your comment in the other guy's post: It seems we do have the same assignment)
Brianna You're welcome :)
Thank you so much Emma , you're a life saver
In the output you are segreegated the reversed integers ...on what basis ?sorry, I didn't understand that part...