def spamFunc(): spam = 1 while True: if spam%2==0: spam+=1 print(spam) elif spam >= 50: print("All done!") break else: spam+=7 print(spam) spamFunc()
welcome back! @CreeperFoot and idk how to improve it as i am kind of new to coding sorry
Hmm, I’m confused. What do you want to improve this for? And what’s it’s purpose?
Welcome back as well.
I really didn’t have anything specific in mind, it was mostly just an exercise, but I wanted to know how (if possible) I could make it cleaner/more efficient.
I’m sorry but I can’t really help you there. The code doesn’t seem to have any practical purpose and I don’t know what you’re trying to achieve. I kind of have to if you want help. I need to know what you need from the code.
Like Danny said, without knowing your intent for the code, it’s kind of a guessing game. However, how about something like this?:
def spamFunc(): while spam < 50: if spam % 2 == 0: spam += 1 else: spam += 7 spam = 0 spamFunc(spam) hero.say(spam)