change the order of numbers from the back

Question:

they need to order with a problem

so I have the text in a certain order of numbers, something like gematria

input [12345] is what we call gematria and what do they need?

they need to line up the digits backwards

[54321]
have a different count and I would need help with that rather than doing twenty different if

def shiftall(s, n):
     n %= len(s)
     return s[n:] + s[:n]

it didn’t help me much it only moves the simple text

Asked By: Nobikk

||

Answers:

For strings:

return s[::-1]

For integers:

return str(s)[::-1]

Note: This would go inside def shiftall(s, n):
Additional note: Now you don’t even need the parameter n

Answered By: Ryan

If you want to reverse a number, then you can convert it to a string, reverse the string, and then convert it back to a number.

num = 12345
str_num = str(num)
# reverse and convert
num = int(str_num[::-1])
Answered By: The Peeps191

input=[12345,43545436,88888,843546]

def shiftall(s):            
d=[]
for i in s:

    res=''.join(reversed(str(i)))

    d.append(int(res))

return d

print(shiftall(input))

Answered By: Nurtazim Bakytov
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.