Piping and redirecting output

I’m having trouble in this mission when trying to run the following line:

/home/dq$ echo -e ‘import random\nfor i in range(10000):\nprint(random.randit(110))’>rand.py
/home/dq$ python rand.py

I get the following error:
File “rand.py”, line 3
IndentationError: expected an indented block

My question is: How do we indent when we are storing code like this in a file and is all a string?

Hi anautf

For indentation, you can add 4 spaces after the \n character.

This shoul be:
echo -e ‘import random\nfor i in range(10000):\n print(random.randit(110))’>rand.py
But you have syntax error in your code

should be randint


should be random.randit(1,10)

So the final code would be:
echo -e ‘import random\nfor i in range(10000):\n print(random.randint(1,10))’>rand.py

Hope this helps.