0
Is there a way to make the elif statement to a single if statement
So the elif statement is so stacked, can i make it shorter? https://code.sololearn.com/cw8i88Zj1CjE/?ref=app
4 Answers
0
Nah bro. Here's my rpg, you'll find lots of those
https://code.sololearn.com/cjGIfr8I4Fu2/?ref=app
+ 1
Julian Yang here is an idea to reduce lines 50 - 78 by using a dict:
wpns = {'1':ss, '2':ls, '3':hd, '4':ar, '5':pg, '6':lc, '7':ex}
if shop2 in wpns.keys():
wpn = wpns[shop2]
player.atk += wpn.atk
player.money -= wpn.price
print ('current attack' + str(player.atk))
print ('money left' + str(player.money))
+ 1
Thanks a lot man Brian
0
Thanks for answering Slick