uaveiro-leci/1ano/fp/aula05/shorten.py

17 lines
327 B
Python
Raw Normal View History

2022-10-20 21:22:14 +00:00
import re
def main():
print(shorten("Universidade de Aveiro"))
print(shorten("United Nations Organization"))
def shorten(string):
abv = ''
upper = r"[A-Z]$"
for char in string:
if re.match(upper, char):
abv += char
return abv
if __name__ == "__main__":
main()