0
I got this question on python challenge, what's the output? And why does this have ; at the end? Python doesn't need that right?
x=67; y=int(".join(sorted(str(x)))); z=int(".join(sorted(str(x)))[::-1]); print(z-y);
5 Respostas
0
Based on my understanding, I add semi-colon to separate two statements in one line.
0
You can also write like this if you want. (although it's ugly, unreadable & very bad practice)
x=67;y=int(".join(sorted(str(x))));z=int("join(sorted(str(x)))[::-1]);
print(z-y);
for the output, why don't you try in code playground and learn how first.
It'll be better for you than straight answer.
0
Ah thanks for the response both of you. I actually did try this code on pycharm but it gave me an error, that's why I came here looking for answer.
0
Can you show me error output?
When i tried above code in sololearn code playground, error is due to using only one double quote (") instead of two ("").
0
Sorry for the late answer, i got it to work, thanks for the help!