Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I would like to know the code of Performing the computation of rotating the list of elements if i type List1[4,5,6,16,25,36] it should give the output as [6,16,25,36,4,5]

Kindly give me an explaination of how it works

Thank you.


What I have tried:

#using the list function
list1 = []


#get user input
for i in range(6):
    num = int(input("Enter number: "))
    list1.append(num)


# Rotate the list to the left twice using the slicing rotation by 1

list1 = list1[2:] + list1[:2]

# Print the output

print(list1)
Posted
Updated 7-Mar-23 1:01am
v2

1 solution

You need to check each square value against its root number, something like:
Python
num = int(input("Enter number: "))
if i > 2:
    base = list1[i - 3]
    if base * base != num:
        print("{} is not a valid entry".format(num))
        break
list1.append(num)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900