Created
February 3, 2025 14:19
-
-
Save adgedenkers/9917c8c3e27dd07526803259a8f3da37 to your computer and use it in GitHub Desktop.
Python is Awesome - Two ways to write the same function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the same function, written two different ways in Python | |
def oddEvenA(number:int) -> str: | |
if number % 2 == 0: | |
odd_even = "even" | |
else | |
odd_even = "odd" | |
return odd_even | |
def oddEvenB(number:int) -> str: | |
return "even" if number % 2 == 0 else return "odd" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment