My input code is
for i in range(len(list1)-1,-1,-1):
The output will be like this in mac os new updated version mac os monetary
Hello, @Jagannath20, and welcome to the Python Forum!
The output from the code is:
list list list list list list list list list
What output are you trying to produce?
Please remember to format code as you post it. You can do this either by selecting all the code and clicking the
</> button above the editing window, or by placing three backticks on a line above the code and three backticks on a line below it.
When I work with this code on windows platfor, the output is 9,8,7,6,5,4,3,2,1
But in the mac os platform I didn’t get the same output after updating my os mac os monetary
You should get the same output on Windows, Mac or any other operating
system. Please double- and triple-check that you are actually running
the same code.
If you are still getting something different on the Mac, please
copy and paste the exact code and output you get.
Don’t forget to format the code and output as code. You can do that
using the Discuss text widget.
You can still edit your original post to format the code. Correctly formatted, it appears as follows, and is much easier to read:
list1=[1,2,3,4,5,6,7,8,9] for i in range(len(list1)-1,-1,-1): print(list[i],end=' ') print()
This line is problematic:
It refers to
list, where you may have intended for it to refer to
Making the change to
list1 leads to the following output on a MacBook Air with Python 10.0:
9 8 7 6 5 4 3 2 1
File “exe”, line 5
for loop in range(c):
SyntaxError: invalid syntax
I dont undertand what is invalid
Did you check the line endings (in Notepad++ you can go to Edit/EOL conversion to make sure)?