error regarding for loop
Title
Question
In [9]: %run -i sqrt_num_list.py
File "C:\Users\gargr\sqrt_num_list.py", line 2
for num in numbers
^
File "C:\Users\gargr\sqrt_num_list.py", line 2
for num in numbers
^
SyntaxError: invalid syntax
the following is the notepad code:
numbers=[4,9,16,25,36]
for num in numbers
print("sqrt of", num, "is", num**0.5)
print("This is outside for-loop")
for num in numbers
print("sqrt of", num, "is", num**0.5)
print("This is outside for-loop")
Python-3.4.3 Getting-started-with-for 03-04 min 30-40 sec
Answers:
<span style="background-color: rgb(250, 250, 250);">Your script has a syntax error in for num in numbers.You need to add a colon after the for statement like this </span>for num in numbers:
Login to add comment