I have a code that looks:
if condition1:
do1
if condition2:
do2
else:
do3
else:
do3
where do2
and do3
operate on the same variables. Is there a way to reduce this code somehow, to avoid having do3
twice?
Thanks!
I would think of something like this to avoid do3 twice
if condition1:
do1
elif condition2:
do2
else:
do3
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.