+ 1

Error in relay race practice code, possible

players = ["Alice", "Bob", "Charlie", "David", "Eve", "Frank"] #Create 3 lists with 2 players each #Use slicing to create a list for Group 1 g1 = players[0:2] #Use slicing to create a list for Group 2 g2 = players[2:4] #Use slicing to create a list for Group 3 g3 = players[4:6] print("Group 1:",g1) #display the 1st group print("Group 2:",g2) #display the 2nd group print("Group 3:",g3) #display the 3rd group This should print the correct code which it does, but the system does not recognize this.

29th Sep 2023, 2:03 AM
Charles Bennett
Charles Bennett - avatar
6 Answers
+ 5
Charles Bennett , please make sure that all relevant information that is required is given from your side when creating the post. it should include: > the programming language (to be placed in tags) > if your post is related to a sololearn tutorial, we need to know the name of it, also the module name / number and lesson / exercise name. > a clear task description with input / output sample > a link that points to your code try > a description what exactly your issue is, (if possible including an error message) btw: the requested output is: Group 1: ['Alice', 'Bob'] ... your output is: Group 1: ['Alice', 'Bob'] ...
29th Sep 2023, 6:35 PM
Lothar - avatar
+ 7
Phantom Xen , your suggestion is totally hard-coded. > the purpose of this exercise is to learn how we can write a code that can handle and print the content in a particular way. btw: the given answer from you is passing the test case. i don't know what sololearn is thinking about accepting this *kind of code*.
4th Nov 2023, 4:34 PM
Lothar - avatar
+ 4
Compare your output and the expected output. Is there any difference?
29th Sep 2023, 2:32 AM
Wong Hei Ming
Wong Hei Ming - avatar
+ 1
Here's a shortcut print(''' Group 1: ['Alice', 'Bob'] Group 2: ['Charlie', 'David'] Group 3: ['Eve', 'Frank'] ''')
4th Nov 2023, 10:33 AM
Phantom Xen
Phantom Xen - avatar
+ 1
Same. I was jk. But sololearn needs to update somethings about the ide even though the code will pass the test case
4th Nov 2023, 8:01 PM
Phantom Xen
Phantom Xen - avatar
Even Though your output and the expected output are the same you won't understand why the test case isn't giving correct. Try this way players = ["Alice", "Bob", "Charlie", "David", "Eve", "Frank"] g1 = players[0:2] g2 = players[2:4] g3 = players[4:6] print("Group 1:") print(g1) print("Group 2:") print(g2) print("Group 3:") print(g3)
10th Jan 2024, 11:29 PM