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.
#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)
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)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)