Python beginner import code

import sys
num_steps = int(sys.argv[1])
for i in range(1, num_steps + 1):
print((’#’ * i).rjust(num_steps, ’ '))```

Does anyone know what does this mistake means and how to fix it? Please, help :pleading_face:

Traceback (most recent call last):
File “”, line 4, in
num_steps = int(sys.argv[1])
IndexError: list index out of range

Perhaps you want argv[0]

I changed it ,cause with 0 it didn`t work as well(

I wouldn’t expect that line to work at all. What do you want to happen when you multiply a character and a number?

I have a university task to create a ladder. I need to transfer a number of steps as a parameter and to draw the ladder onto the console using # and space’ ’ symbol

OK. That will work, but you will need to fix your characters. Your single quote looks funny. Try '

You can see something is up wrong because there is that red squiggly line. Overall everything after ' #' * i looks funny in the editor, which is a big red flag.

The code looks better. What number did you pass in the command line?

i just ran it, though it still has some kind of problem, maybe this one is better?

num_steps = int()
for i in range(1, num_steps + 1):
    print(("#" * i).rjust(num_steps, ' '))

I’m not sure why you changed this. The code you had before,

num_steps = int(sys.argv[0])

was what you wanted.

You never said what number you are passing in on the command line.