I want the first if ... else statement to check both a and b simultaneously. And I want an efficient way of counting no_of_good and no_of_poor in order to minimize the number of lines of code. Is it possible?
How can I print both a and b as good in if statement? And also how to calculate good and poor count?
a = 1
b = 3
good_count=0
poor_count=0
if a in range(0,6) and b in range(0,6):
//print and count
elif a in range(6,10) and b in range(6,10):
//pprint and count
This is a long method of doing the work:
a = 1
b = 3
good_count=0
poor_count=0
if a in range(0,6):
print("a = GOOD")
good_count+=1`
elif a in range(6,10):
print("a = POOR")
poor_count+=1
if b in range(0,6):
print("b = GOOD")
good_count+=1
elif b in range(6,10):
print("b = POOR ")
poor_count+=1
print("no_of_good=",good_count," ","no_of_poor=",poor_count)
Actual output:
a = GOOD
b = GOOD
no_of_good= 2 no_of_poor= 0
Expected output should also be same but by using any different method
nameof the variables, you can just use a list, like my answer below!