Skip to content

Instantly share code, notes, and snippets.

@twitu
Last active September 17, 2023 15:30
Show Gist options
  • Save twitu/f958152b63971b319a4a0782285d9901 to your computer and use it in GitHub Desktop.
Save twitu/f958152b63971b319a4a0782285d9901 to your computer and use it in GitHub Desktop.
Pop those crackles
# Crackle pop game for numbers
# Print Crackle for multiple of 3
# Print Pop for multiple of 5
# Print CracklePop if multiple of both
# Print the number if not multiple of either
def cracklepop(n):
for i in range(1, n + 1):
if i % 3 == 0 and i % 5 == 0:
print("CracklePop")
elif i % 3 == 0:
print("Crackle")
elif i % 5 == 0:
print("Pop")
else:
print(i)
if __name__ == "__main__":
cracklepop(100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment