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 it can be liked by you.
Note:
If there is no odd digit in the number, do not rotate it.
If a number starts with an odd digit, do not rotate it.
Input
The first line of input contains space-separated integers.
sample input1
21 503 256 550 86 979 281
sample output1
12 503 562 550 86 979 128
sample input2
2001 463 6219 669 473 1006 77734 110 20511
sample output2
1200 346 1962 966 734 1006 77734 110 51120
def func1(list1):
list2 = []
for i in list1:
j = str(i)
if int(j[0]) % 2 == 0:
for k in range(len(j)):
if int(j[k]) % 2 == 1:
list2.append(j[k:] + j[:k])
break
else:
list2.append(j)
return list2
numbers = input().split()
print(func1(numbers))
Comments
Leave a comment