I have an in list question in the conditional statement!

Asked 2 years ago, Updated 2 years ago, 15 views

TestA = [TestB, 'gold' ,'void']

TestB = ['Test', 130]

testa testb and in the number is

if there are more than 150 or, ‘test’ in the testb

-> 'Check Test B'

If there is a TestB in TestA, there is no 'test' in TestB, or the number is less than 150,

-> 'Check Test C'

If there is no TestB in TestA

-> 'Check again'

In the equation that I've solved in these problems, I'm going to

if TestB  in  TestA :

  check = 0

  If 'test' in TestB:

    print ('test B verification')
    check += 1
    elif TestB[0] >= 100 in TestB :
        if check == 0 :
          print ('test B verification')

I'm solving it like this I'm not sure if I've answered the question and understood the way I'm solving it. I wasn't sure if the elif TestB[0] >=100 in TestB was right

python

2022-09-20 16:30

1 Answers

There are other ways, but I think we need to do this if we want to do a separate condition of 150 or higher.

TestB = ["Test", 130]
TestA = [TestB, 'gold' ,'void']

if TestB in TestA:
    c = [i for i in TestB if str(type(i)) == "<class 'int'>"]
    print(c)
    if 'test' in TestBor max(c) >= 150:
        print ('test B verification')
    If 'test' not in TestBormin(c) < 150:
        print ('Check Test C')
else:
    print ('re-check')


2022-09-20 16:30

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.