34 lines
668 B
Python
34 lines
668 B
Python
#!/usr/bin/env python3
|
|
|
|
import logging
|
|
logging.basicConfig(level=logging.INFO, format="%(funcName)s %(levelname)s: %(message)s")
|
|
|
|
def while_loop() -> None:
|
|
"""
|
|
while loop which requires a counter
|
|
"""
|
|
counter: int = 1
|
|
while counter <= 5:
|
|
logging.info(counter)
|
|
counter += 1
|
|
|
|
def for_loop() -> None:
|
|
"""
|
|
for loop which puts the counter inline
|
|
"""
|
|
for i in range(5):
|
|
logging.info(i)
|
|
|
|
# Main function
|
|
def main() -> None:
|
|
"""
|
|
Both functions will log a message 5 times, but the for loop is so much simpler
|
|
"""
|
|
while_loop()
|
|
for_loop()
|
|
|
|
|
|
# Call main function
|
|
if __name__ == '__main__':
|
|
main()
|