Function and condition
def is_even(number):
return number % 2 == 0
Practice typing real code syntax, including brackets, punctuation, and indentation. Snippets are for typing practice only and are never executed.
def is_even(number):
return number % 2 == 0
numbers = [3, 8, 12, 5, 10]
even_numbers = []
for number in numbers:
if number % 2 == 0:
even_numbers.append(number)
print(even_numbers)
words = ["code", "learn", "code", "practice"]
counts = {}
for word in words:
counts[word] = counts.get(word, 0) + 1
for word, count in counts.items():
print(f"{word}: {count}")