+ 6
I have a question in Python! Which code outputs this???? 1,2,3,4,5,6,7,8,9,10
I mean the code must divide the numbers by comma in one line! I need different Code! not like print(1,2,3,4,5,6,7,8,9,10)
24 Answers
+ 11
There are several (and better) ways to
do that, i guess.
https://code.sololearn.com/ch04ymTr1cw8/?ref=app
+ 10
Jakub, that's a nice one! :D
Is there a way to remove the brackets "[ ]" in the console output... ? I am not so good in Python yet. :P
+ 10
Jakub, it works, thanks for share!
$Vengat i was referring to the Jakub's solution (cleaner than mine with loops), your solution checks the last value and remove the comma, i also made something similar but i opted for an easiest solution, just putting a further print statement at the end.
Goodnight people! :P
+ 9
See it works
https://code.sololearn.com/cOKQ0zZ40Hu5/?ref=app
I am free to help out in any Pythonian stuff and non-advanced stuff. Kuba is always the best
+ 8
@Maz you can do:
m=len(list)-1
for i in list:
print(i, end="")
if m:
print(",",end="")
m-=1
+ 8
@Sk krish he doesn't want the bracket
+ 8
Goodnight!
Have lots of rest and dont wake up at 2.45am to do sololearning >:P
+ 8
@Sk for someone who claims to be bad at Python that is pretty awesome.
+ 8
jakub's answer is very easy & I love it
+ 8
Yeah it is easy to create the list.
I am inspired of making a (no. of ways) to do something series :)
+ 7
The sep and end function define what you want at the end.
sep and end are at default "\n".
So we have
for count in range(1,11):
print(count, end(or you can use sep)='')
Note that the end or sep can be anything you want.
+ 7
@Sk my code is answer
+ 7
good Night maz!
+ 7
That's what makes me so (moderately) good at ir. I am hooked to Pythonian simplicity
+ 7
Okay Sk I will make my code and do homework
+ 6
I think you can change "[]" brackets into tuple()
+ 6
@Maz we can do it, lets get fancy:
print(", ".join(map(str, range(1,11))))
+ 6
@$Vengat yeah! don't need brackets! I'm expecting that!
+ 6
@maz your code also pretty awesome!
+ 6
vengat Python is little awesome!