r/learnpython • u/Shut_up_and_Respawn • Feb 12 '24
Day 2 of learning python. I made the most complicated code I could that counts to 10
counter = 0
while counter < 5:
counter += 1
print(counter)
if counter < 5:
function = True
if True:
print(6)
if True:
dex = 5
while dex < 6:
dex += 1
print(7)
if dex <= 6:
print(8)
if dex <= 6:
hp = 5
while hp > 4:
hp -= 1
print(9)
if hp >= 4:
fax = 10
if fax != counter:
print(10)
2
Upvotes
3
u/moving-landscape Feb 12 '24
Tip: if True is as good as no if block at all. You don't need the extra level of indentation.
1
u/Shut_up_and_Respawn Feb 12 '24
I know, Im just trying make it complicated
1
u/moving-landscape Feb 14 '24
I see now what you were trying to do.
Hey, why not use some variables since the goal is to unnecessarily complicate it? In place of
if True, how aboutenter_this_block = True if enter_this_block: # increment count skip_this_block = False if not skip_this_block: # ...1
u/Shut_up_and_Respawn Feb 14 '24
The reason is because I hadnt gotten to that point of learning yet. In that program, I was just trying to use the things I knew as much and in as many different ways as possible. I still have not learned that stuff yet
6
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 Feb 12 '24
I don't really see the point, but good for you!
The indentation is broken, though. I'm assuming this is what you meant.