-3

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

Nobikk
  • 19
  • 1
  • 1
  • 5

3 Answers3

1

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

Ryan
  • 1,081
  • 6
  • 14
  • 1
    `test = "1234" print(test[::-1])` yes thanx :D it didn't occur to me that it could also work with whole numbers, I learned something new again, thank you – Nobikk Jul 22 '22 at 19:20
0

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])
The Peeps191
  • 153
  • 1
  • 8
-1

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))