0

What is incorrect in this code

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] # Display the 1st group print("Group 1: \n",g1) # Display the 2nd group print("Group 2: \n",g2) # Display the 3rd group print("Group 3: \n",g3)

9th Jan 2025, 12:16 AM
Veena Vijay
Veena Vijay - avatar
5 Respostas
+ 1
why do you say it's incorrect? It's a good code.
9th Jan 2025, 5:15 AM
Bob_Li
Bob_Li - avatar
+ 1
There's nothing wrong with the code from what I've seen Why are u saying something is incorrect?
9th Jan 2025, 6:06 AM
DashFR
DashFR - avatar
+ 1
the code is functioning as intended and there are no errors.
9th Jan 2025, 6:58 AM
Mustafa Raza
+ 1
Veena Vijay , the code seems to be correct since it does not raise any exception. but the output is *not* as expected. > this is an exercise called `relay race` from the python tutorial `python developer`. # the output of the current code is: Group 1: ['Alice', 'Bob'] Group 2: ... this is *not correct*. the line with the names should start *without a space* at the beginning of the line like: Group 1: ['Alice', 'Bob'] Group 2: ...
9th Jan 2025, 8:43 PM
Lothar
Lothar - avatar
0
Lothar good catch. I didn't realize it was a code exercise problem. Yeah, those can be strict with spaces, spelling and capitalization. my more_itertools code also don't work there, it seems like installing modules is restricted, so I deleted it to avoid confusing people...
9th Jan 2025, 9:49 PM
Bob_Li
Bob_Li - avatar