From d24c0fcbb72bad8b2699ea7bd648f5e076fa99ad Mon Sep 17 00:00:00 2001 From: TiagoRG <35657250+TiagoRG@users.noreply.github.com> Date: Wed, 17 May 2023 10:30:19 +0100 Subject: [PATCH] [FP] Quick simplifications --- 1ano/1semestre/fp/aula02/age.py | 2 +- 1ano/1semestre/fp/aula05/shorten.py | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/1ano/1semestre/fp/aula02/age.py b/1ano/1semestre/fp/aula02/age.py index 0b17f82..f43cbfe 100755 --- a/1ano/1semestre/fp/aula02/age.py +++ b/1ano/1semestre/fp/aula02/age.py @@ -16,7 +16,7 @@ print("Age:", age) if age < 13: cat = "child" -elif 13 < age < 20: +elif age < 20: cat = "teenager" else: cat = "grown-up" diff --git a/1ano/1semestre/fp/aula05/shorten.py b/1ano/1semestre/fp/aula05/shorten.py index 0541025..4d2c969 100755 --- a/1ano/1semestre/fp/aula05/shorten.py +++ b/1ano/1semestre/fp/aula05/shorten.py @@ -4,11 +4,7 @@ def main(): def shorten(string): - abv = '' - for char in string: - if char.isupper(): - abv += char - return abv + return ''.join([char for char in string if char.isupper()]) if __name__ == "__main__":