Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
57 views
in Technique[技术] by (71.8m points)

Passing an array as an argument in Python

I'm not sure if this is even possible but I'm trying to create a python program that identifies polynomials and identifies all the properties of them. I was trying to make a function similar to the switch() function, and the way that I was going to get around making hundreds of functions for each number of cases for arguments, I wanted to make one of the arguments an array, currently it's throwing me a bunch of errors and I really don't know what I'm supposed to be doing because they don't explain themselves, I've looked around and haven't found anything that works, any help would be greatly appreciated, I'm fairly certain there is a similar function in python but any articles on it are quite confusing, thank you, below is the function I was trying to make.

def switch(checked, check):
    for(item in check):
        if(item == check):
            return True
    
    return False
question from:https://stackoverflow.com/questions/65904959/passing-an-array-as-an-argument-in-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Did you mean this?

def switch(checked, check):
    for item in check:
        if item == checked:
            return True
    return False

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...