Having a issues

My input code is

for i in range(len(list1)-1,-1,-1):
print(list[i],end=’ ')
list [0]=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[8] list[7] list[6] list[5] list[4] list[3] list[2] list[1] list[0]

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

Hi Jagannath,

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.

1 Like

You can still edit your original post to format the code. Correctly formatted, it appears as follows, and is much easier to read:

for i in range(len(list1)-1,-1,-1):
  print(list[i],end=' ')

This line is problematic:

  print(list[i],end=' ')

It refers to list, where you may have intended for it to refer to list1.

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)?