ChatGPT python code doesn't work, need help

Hello all,

I created python code through ChatGPT, once Im inserting it into python node in GH it dont work,

I`d need help of people who can know what is wrong.

this is description of what do I need:

Python code for Grasshopper node, if input value x between 0-19 then output value a=0, if input value x between 20-39 then output value a=1, if input value x between 40-59 then output value a=2, if input value x between 60-79 then output value a=3, if input value x between 80-100 then output value a=4.

this is the result from chatGPT code:

Thank you for help.

Hi @ivan.stratiichukupwo ,
Try deleting the line:

x = input_value
3 Likes

It work, thank you.

1 Like

What @djordje said yes.

I’ve noticed ChatGPT will often add these lines to try and give you “default values” to work with in testing a script but since it is unaware you are most likely already giving values within the grasshopper environment it more often than not gets in the way.

And the reason it isn’t working specifically is that your code is comparing against x but your line that you removed is just telling the script that x = input_value but input_value is not defined as the error points out.

If, your script input was named input_value instead of x than that would also work because it would be reading the value of input_value from your slider value.

2 Likes

Assigned to Scripting category.