+ 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.
9 ответов
+ 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']
...
+ 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*.
+ 4
Compare your output and the expected output.
Is there any difference?
+ 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.
+ 2
Here's a shortcut
print('''
Group 1:
['Alice', 'Bob']
Group 2:
['Charlie', 'David']
Group 3:
['Eve', 'Frank']
''')
+ 2
Same. I was jk. But sololearn needs to update somethings about the ide even though the code will pass the test case
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)
0
no no que estupidez
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