+ 2

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
9 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
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
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
+ 3
Fatih Urgen , (1) > the output of your code sample does not show the required result. (see the comment in my first answer above). it should be done in 2 lines. (2) > converting the slice (list of 2 elements) to a string will result in: "['Eve', 'Frank']" which is no longer a list but a string.
29th Oct 2024, 10:45 AM
Lothar
Lothar - avatar
+ 2
Here's a shortcut print(''' Group 1: ['Alice', 'Bob'] Group 2: ['Charlie', 'David'] Group 3: ['Eve', 'Frank'] ''')
4th Nov 2023, 10:33 AM
яуоiснi ᵍʳᵉʸ
яуоiснi ᵍʳᵉʸ - avatar
+ 2
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
яуоiснi ᵍʳᵉʸ
яуоiснi ᵍʳᵉʸ - avatar
0
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
VIJAY BANGARU ABIRAM KOTANI
VIJAY BANGARU ABIRAM KOTANI - avatar
0
no no que estupidez
29th Jun 2024, 1:08 AM
mario manrique diaz
mario manrique diaz - avatar
0
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:" + str(g1)) #display the 1st group print("Group 2:" + str(g2)) #display the 2nd group print("Group 3:" + str(g3)) #display the 3rd group
28th Oct 2024, 9:40 PM
Fatih Urgen