0

I want to change this python3 code:

for i in range(3,70):
    print (i)

into code that runs in macOS Mojave terminal

I am guessing something like:

for i in {3..70}; do print(i); done 

?

Math Avengers
  • 762
  • 4
  • 15

2 Answers2

1

Close but - use echo instead of print. With the following bash syntax:

for i in {3..70}
do
    echo $i
done

This question has a wealth of information on this topic:

How do I iterate over a range of numbers defined by variables in Bash?

jwDavis
  • 63
  • 2
  • 6
0

If you want to use a variable instead of constant values, you can use this:

for i in $(seq 1 $VAR); do echo $i; done

chwala
  • 199
  • 10