New course! Every coder should learn Generative AI!
Try a free lesson0
Is there any method for number reversible in Python?
4 Answers
+ 1
Cbr✔[ Most active ]
I am quite sure this code won’t run
you made a typo I think :)
check the end of your reversed variable :)
0
You mean a method to reverse numbers ?
Like 123 => 321 ?
0
you can use numbers in a list and reverse the list
lst = [1,2,3]
rev_lst = lst[::-1]
print(lst)
print(rev_lst)
you can also use lst.reverse()
beware there is a difference
the reverse() function reverses the list so that lst is now in reverse. it actually changes the list
the first option, [::-1] is just a different way of printing the original list
0
https://code.sololearn.com/cWGyRXm9rC8i/?ref=app
wrote some example code