Python passing variable in a function

So I am trying to pass X from test() to rfid() to be tested and it wont work:

This is what I have:

def test(x):
        testcard = 8974
        x=testcard
        return x


def rfid():
        #This will just see if the rfid chip has enough digits

        main= 8974

        # This looks to see if the rfid chip has enough digits to pass the test

        if main == x:
                print ("Card read check complete")
                cardlength= info[main + readlen]
                main += readlen + 1
                return True,info[main:main + cardlength]
        else:
                        main += readlen + 1
        return False,0,''


def main():
        rfid(x)

main()

Answers


First, you have to fix this:

def rfid(x):
    # ... rest of code

You see, if a function needs a parameter it must be declared as such. Next, you have to actually call rfid() from test():

def test():
        x = 8974
        return rfid(x)

And in main(), call test(). Or just call test(), there's no need to declare and call main():

def main():
        test()

main()

Need Your Help

Relating mismatched column in an xsd?

visual-studio-2008 reporting-services join dataset

I am using VS 2008 and trying to create a dataset for ms sql reporting services. I have two tables that I want to relate. One has a column with type of int, the other shortint. VS give me an err...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.