+ 1

reversed number

There are two ways to create the program that will give you a reversed version of the number that you put in. Are these two codes readable,guys? first way: a=int(input("enter a number here")) print(a) x=a%10 y=a//10 y=str(y) print(str(x)+y[::-1]) second way: a=str(input("enter a number here")) x=a[: :-1] print(x)

27th Dec 2018, 12:27 AM
Khai123
Khai123 - avatar
3 Respostas
+ 3
There are LOTS of ways. Here are 2. one long and one short. number=str(input()) def flip(x): num=[] rev="" for i in range(len(x)): num.append(x[i]) num.reverse() for i in num: rev=rev+i return rev print(flip(number)) print(str(input("Enter a number: "))[: :-1])
27th Dec 2018, 1:19 AM
LordHill
LordHill - avatar
+ 1
Yeah they are
27th Dec 2018, 2:03 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
thanks bro
27th Dec 2018, 2:05 AM
Khai123
Khai123 - avatar