How to check if a tuple contains an element in Python?

前端 未结 3 982
灰色年华
灰色年华 2020-12-16 11:56

I tried to find the available methods but couldn\'t find it. There is no contains. Should I use index? I just want to know if the item exists, don\

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 12:50

    Be careful with that: return Oops. use Set: d= {...}

    def simha():
        d = ('this_is_valid')
        b = 'valid'
        if b in d:
            print("Oops!!!!!")
    
    
    simha()
    

提交回复
热议问题