Home > Back-end >  How to fix the error "( " was not closed in python?
How to fix the error "( " was not closed in python?

Time:01-31

VS Code says that "(" was not found:

class planta:
    def __init__(self,a[]):
        b=10000
        for i in a.len():
            if a[i].values<b:
                b=a[i].values
        print(b)

CodePudding user response:

Python parameters don't use explicit datatypes. Removing the [] from the __init__ function will fix your error.

CodePudding user response:

Well, in the second row, expression "a[]" is not appropriate in python. You should change it to just "a" if a is a iterable object.
Also, in the fourth row, a.len is not a method nor a attribute(method or attribute "len" is not defined in the 'object' class, which is the parent class to all classes in python). If you want to obtain the length of 'a', you should change 'a.len()' to 'len(a)'.

  •  Tags:  
  • Related