Bar | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Bar

I want to make a bar that can increase or decrease depending on a variable (that has a max that can be increased). the bar won't be shown all the time or increased over time (like a loading bar). what's the best way to do it? basically like a health bar. EDIT: this is for python shell

3rd Apr 2018, 9:21 PM
error505
4 Answers
3rd Apr 2018, 11:53 PM
Emma
+ 2
I'm starting to go a bit overboard with mine :D finished maxhp buff, potion and damage/armor additions :D I think I'll add the hp thing i made .D max_hp = 100 current_hp = 60 def healthbar(max_hp, current_hp, *args): base = "[||||||||||]" calc = int(((max_hp - current_hp) / 10)) if calc != 0: print(base[0:-calc], end="") print(" "*(len(base)-len(base[0:-calc])), end="") print("]") else: print(base) print(current_hp) healthbar(max_hp, current_hp)
4th Apr 2018, 5:51 PM
Markus Kaleton
Markus Kaleton - avatar
0
made my own version of the code https://code.sololearn.com/c8cN2vinVYFs/?ref=app
4th Apr 2018, 3:16 PM
error505
0
Markus Kaleton Great to see an alternative solution ☺
4th Apr 2018, 5:58 PM
Emma