x = Tuple("10","20","30","40","50") Tuple =("10","20","30","40","50") print("reverse") whats wrong on my code help pls | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

x = Tuple("10","20","30","40","50") Tuple =("10","20","30","40","50") print("reverse") whats wrong on my code help pls

Python

26th Sep 2020, 8:25 PM
Arlyn dela Cruz
Arlyn dela Cruz - avatar
3 Answers
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..
26th Sep 2020, 8:35 PM
Jayakrishna 🇮🇳
0
Can you give me the correct code
26th Sep 2020, 8:51 PM
Arlyn dela Cruz
Arlyn dela Cruz - avatar
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..
27th Sep 2020, 12:30 PM
Jayakrishna 🇮🇳