2/25/2021 6:27:14 AM
Roza Simonyan8 Answers
New AnswerRoza Simonyan No. but you can try like this a = 10 b = 20 min = a if a < b else b print (min)
no 'clasic' short conditional operator, but you could write onelined assignable if..else: value = 42 if condition else 0
It can use python ternary operator in list comprehension my_list = list(range(1,11)) result = ['yes' if a%10==0 else 'No'] The statement inside the list is an example of python ternary operator
Simple answer. Passes all test cases. Change nothing. Add this in side code instead and to_cash >=500 #"and" as you know, makes another condition to follow. Like, this AND that. The rest is already written. Thank you for reading ❤️ I hope this helps
A complex sample: age = int(input()) print("baby" if age<1 else "toddler" if age<3 else "preschool" if age <5 else "grade school" if age<12 else "teen" if age<18 else "young adult" if age <21 else "adult" if age<39 else "middle aged" if age<59 else "old") 😀
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message