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)
5 Respostas
+ 1
why do you say it's incorrect?
It's a good code.
+ 1
There's nothing wrong with the code from what I've seen
Why are u saying something is incorrect?
+ 1
the code is functioning as intended and there are no errors.
+ 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:
...
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...