SPECIAL NUMBERS
you only like numbers that start with an odd digit. anil gives you space-separated integers as input . your task is left-rotate every number in the list (if required) so that can be liked by you.
NOTE:
INPUT :
The first line of the input contains space-separated integers
OUTPUT:
The out should be a single line containing space separated integers with odd digit as first digit for each number.
EXPLANATION:
in the example, input is 21, 503, 256, 550, 86, 979, 281
Rotate all the words to the left so that each number starts with an odd digit .
Input1: 21 503 256 550 86 979 281
Output 1: 12 503 562 550 86 979 128
Input 2: 2001 463 6219 669 473 1006 77734 110 20511
Output 2: 1200 346 1962 966 734 1006 77734 110 511120
def func1(list1):
list2 = []
for i in list1:
j = str(i)
if int(j[0]) % 2 == 0:
for k in range(len(j)):
j[k] = j[len[j]-k-1]
list2.append(j)
return list2
func1([12, 252,2125])
Comments
Leave a comment