+ 1
Code Simplifying And Correcting
the code link is https://code.sololearn.com/ciXQqB0bR8D8 plz see the question commented there in the link. sololearn is not allowing it to be typed here because of word limits
2 Réponses
+ 2
ARNAV MOHAN floor division makes this simpler. Presumably the contents of the list will be used later, otherwise you only need to input the length - not the list itself.
x=list(input("ENTER THE VALUE TO CALCULATE THE MIDDLE ELEMENT'S INDEX: "))
y=len(x)
a = (y+1)//2
if (y%2):
print("\nTHE INDEX OF THE MIDDLE ELEMENT IS:", a)
else:
b = a+1
print("THE INDICES OF 2 MIDDLE ELEMENTS ARE:", a, "&", b)
+ 1
@Brian Thanks friend:)