Im trying to use a variable value in the range() in for loop as shown in the below code
n = int((length 15) / 16); n is being calculated and typecasted to int
for j in range(n)
For which im getting sytax error. could anyone tell how exactly to solve this
CodePudding user response:
n = int((length 15) / 16); n is being calculated and typecasted to int
The above line is not valid python. The comment you made needs to have #
and not ;
suffix to let python know the following part is a comment. So by replacing ;
with #
, you code becomes syntactically valid.
n = int((length 15) / 16) # n is being calculated and typecasted to int
The above line is.
CodePudding user response:
In Python Comments starts with a #, and Python will ignore them:
# this is comment
print('something')
Comments can be placed at the end of a line, and Python will ignore the rest of the line:
print("Hello, World!") #This is a comment
so your code should be:
n = int((length 15) / 16) # n is being calculated and typecasted to int
for j in range(n):
# continue