Top MNC interview question which will be very useful for beginners to crack the interview and for there future careers

test

Breaking

Post Top Ad

Your Ad Spot

Monday, January 4, 2021

CGI Interview Question(Swapping first and last digits of the number in Python)

Question:

 Swapping first and last digits of the number

Explanation:

We need to swap the first and last digits of the number

For Example:

                     Number=12345
                    Result=52341
Program:

list1=[]
n= int(input("Enter the number of elements in list:"))
for x in range(0,n):
    element=int(input("Enter element" + str(x+1) + ":"))
    list1.append(element)
temp=list1[0]
list1[0]=list1[n - 1]
list1[n - 1]=temp
print("New list is:")
print(list1)

                                                                ---------End---------

Post Top Ad

Your Ad Spot