Please tell me about * and sep in print (*[1,2,3], step=')

Asked 1 years ago, Updated 1 years ago, 74 views

Hello :)

School solves the descending output problem

I solved it like this

s = sorted(list(input()))[::-1]

Looking at the other answer,

print(*sorted(input())[::-1],sep='')

*and sep. It's my first time seeing it, so I'm asking you this question.

python print

2022-09-22 17:56

1 Answers

Self-answer after seeing the comments

What value are you going to put in between sep.

print(1,2,3, sep=‘X’) 1X2X3 output like this

* is unpacking

*[1, 2, 3] If you say it, 1, 2, 3 comes out That is, print (*[1,2,3], step='') Then print (1,2,3, sep='') It's done Output is 123


2022-09-22 17:56

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.