+ 1
Help how to remove the [] , & '' sir?
Write a program in python to sort the values below Input: 25 22 19 36 77 50 32 Output: 19 22 25 32 36 50 77 Thank you Edit : I try this my code https://imgur.com/gallery/dkwHzDK
2 Respostas
+ 3
# The best help for you is to learn from Sololearns Python tutorial. Next time please save your attemps code here on playground and link with your question.
print(*x)
+ 2
1. Linking a screenshot of your code is a terrible way to share it. You should save it in the Sololearn playground, and use the big plus icon here to link to your code.
2. You are sorting text, not numbers. If you add the number '9' to the list, it will be sorted as last, because this is alphabetical sorting. To do numeric sort, you should convert every list element to integer (you can use the int() function).
3. In terms of the output the default way of python to print a whole list is indicating it's "listness" with the braces. If you want to print each element you can follow multiple strategies. You can convert the whole list to a single string with the join() method and specifying a custom separator:
print(' '.join(x))
Or you can give the unpacked elements to the print and specify a separator argument:
print(*x, sep=' ')
Or you can also write a for loop and print each value individually but override the end argument:
for value in x:
print(value, end=' ')