I am trying to write a code which will generate a nested list and the main list in a reverse order:
1.my_third_list = ["WHAT","IS","THIS",["a nested list", 3, 8, 4.00]]
meaning, once i print the code, the output that i want to see is:
[4.0, 8, 3, 'a nested list'],'THIS', 'IS', 'WHAT']
the command that i wrote for this:
2.print(my_third_list[:[[3][::-1]]:-1])
but instead of the wanted output, i get this type error:
TypeError: slice indices must be integers or None or have an __index__ method
why does it happen? did i write the command wrong? how can I fix this?
thanks for helping
have a great day
1.my_third_list = ["WHAT","IS","THIS",["a nested list", 3, 8, 4.00]]
meaning, once i print the code, the output that i want to see is:
[4.0, 8, 3, 'a nested list'],'THIS', 'IS', 'WHAT']
the command that i wrote for this:
2.print(my_third_list[:[[3][::-1]]:-1])
but instead of the wanted output, i get this type error:
TypeError: slice indices must be integers or None or have an __index__ method
why does it happen? did i write the command wrong? how can I fix this?
thanks for helping
have a great day