0
x = Tuple("10","20","30","40","50") Tuple =("10","20","30","40","50") print("reverse") whats wrong on my code help pls
3 Respostas
0
x = ("10","20","30","40","50")
#Tuple("10","20","30","40","50")
print(tuple(reversed(x))) #print(*reversed(x))
Arlyn dela Cruz
Tuple don't have reverse method..
"reverse" what ever you add in between quotes is becomes string. Not a function.
reversed(x) don't modify original tuple x. So returns a new list.. Make that to a new tuple or unpacking by * will give you returned list..
0
Can you give me the correct code
0
#I already given corrected code above.. 1st, 3rd lines. Copy paste this.. In playground Arlyn dela Cruz
#corrected code :
x = ("10","20","30","40","50")
#Tuple("10","20","30","40","50") #error, not need this
print(tuple(reversed(x)))
#print(*reversed(x)) #alternative..