0
Q:

reverse python3

# create list of integers or strings 
number = [1,2,3,4,5]
# pass the values using the reverse method.
number.reverse()
# Then print the variable as such:
print(number)
1
arr = [2,5,32,86,4,131,97]

# reverse without modifying input, using range:
for i in range(len(arr)-1, -1, -1):
    print(arr[i])
    
# reverse and modifying input:
arr.reverse()

0

New to Communities?

Join the community