Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cant print whithouth brackets

import random
n=[random.randint(10,999) for i in range(int(input()))]

print(n,end=', ')

there is problem i need it to print whithouth squared brackets how i can change my code by not overcomplicating it
here is what it prints out
[385, 396, 37, 835, 376],
and it needs to look like this
305, 396, 37, 835, 376
I have tried puting brackets in multiple places also i have tried deleting things and all that hapens is it prints the same thing or there is error

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Convert the ints to strings and use join:

>>> n = [385, 396, 37, 835, 376]
>>> print(", ".join(map(str, n)))
385, 396, 37, 835, 376

Another option is to use the * operator to spread n as multiple arguments to print:

>>> print(*n, sep=", ")
385, 396, 37, 835, 376
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading