0
My code output is broken
import random XYZ = ["yes", "no", "try again", "im confused", "forgetaboutit", "when pigs fly", "your luck would be better spent on a lotto ticket"] print(random.sample(XYZ, 1)) that is my code. why is that out put always inside of [' '] ? the code in the playground: https://code.sololearn.com/cfrVU5beJ4S7/?ref=app
5 odpowiedzi
+ 7
Try print(random.choice(XYZ))
+ 3
This is exactly what it's suposed to do though.
sample returns a new list.
So, you're just printing a different list.
For example,
If you wrote: print(XYZ);
It would still have those brackets.
The brackets are just showing what is inside the list, which is shown when you print a list.
+ 2
Yes. Do what @David said.
+ 2
ok! that worked! thank you so much!
0
is there any way to tell it to not put it in the brackets?