28th Sep 2020, 1:35 PM
Smiley[Offline]
2 Antworten
+ 3
d = sorted("cda") =>results list as d = ['a', 'c', 'd' ] a, b, c = d means => a= d[0], b = d[1], c =d[2] => so now a='a' ,b='c', c='d' d = c, b, a so now => d[0] =c , d[1] = b, d[2] =a =>hence d =['d','c','a'] print("". join(d)) => prints "dca"
28th Sep 2020, 2:01 PM
Jayakrishna 🇮🇳
+ 2
1. d is assigned to ['a', 'b', 'c'] (sorted() will sort the elements in ascending order, returning a list) 2. a is assigned, to d[0] b to d[1], c to d[2] 3. d is assigned to c, b, a(tuple) so d = (c, b, a) 4. A string is printed, consisting of the elements of d, joined by "" (nothing), so the string is "cba"
28th Sep 2020, 2:01 PM
G B
G B - avatar