Answer to Question #282664 in Python for rahul

Question #282664

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:

  1. if there is no odd digit in the number , do not rotate it.
  2. if a number starts with an odd digit , do not rotate it


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


1
Expert's answer
2021-12-27T08:41:09-0500
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])
                
                
                
            

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS