Hello
this is continuation from my previous topic
this is the full error message
NameError Traceback (most recent call last)
in
26
27
—> 28 for i in range(m):
29
30
NameError: name ‘m’ is not defined
I can provide the full code upon request
TMosh
August 2, 2022, 2:24am
2
Please provide a link to your previous topic.
I don’t think it’s really helpful but sure
Hello everyone,
I am beginner when it comes to python and I faced an issue where I get this message.
“NameError: name ‘w’ is not defined”
I have browsed the forum a bit and found common solutions such as running all cells using the “run all” in the cell tab to be futile
Witch leads me to the conclusion that this is an error in my code, who can I message for assistance in this embarrassing matter?
Thank you all for your patience and assistance.
TMosh
August 2, 2022, 2:59am
4
For example, ‘m’ is defined by the one of the lines of code in the compute_cost() function cell:
When the compute_cost() function is called with the appropriate parameters for x, y, w, and b, the ‘m’ variable will be set to match the number of rows in the ‘x’ matrix. That is, the number of training examples in the ‘x’ data set.
TMosh
August 2, 2022, 3:00am
5
If you’re working on the gradient_descent() function, there is a similar line of code there for the ‘m’ value.
I think you are better to check the indentation level, which is an essential to define a code block for Python.
Here is a good summary by Raymond.
In your case, I guess, even “m” is defined before, if an indentation of “for i in range(m):” is not correct, then, this is a possible error. Here is an example of a bad case.
And, here is a good case.
Please double check.
1 Like
oh thank you for this answer my code works perfectly now!
Hello Friends , I am beginner , I faced an issue where I get this message. “ File “”, line 29
return total_cost
^
IndentationError: expected an indented block
Pleasehelp me What i do ?
TMosh
August 27, 2023, 5:16am
9
Correct indentation is critical when programming in python. It uses indentation to identify blocks of code.
If you do not have experience programming in python, I recommend you take a python tutorial course right now, and come back to this course later.
Thanks for the suggestion. Pls suggest how can take ?
TMosh
August 27, 2023, 6:40am
11
There are lots of python courses and tutorials available online.
Here is one (it’s a series of videos organized in a playlist).
https://www.youtube.com/playlist?list=PLJR1V_NHIKrCkswPMULzQFHpYa57ZFGbs