Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
2680 - Poezie
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Rezolvare == <syntaxhighlight lang="python" line="1"> # 2680 Poezie def validare(nr_versuri, lista_versuri): # functia de validare a datelor de intrare if len(lista_versuri) != nr_versuri: raise ValueError if nr_versuri > 15: raise ValueError # daca nu sunt valide datele de intrare se va ridica eroarea ValueError for vers_neverificat in lista_versuri: for caracter in vers_neverificat: if caracter.isalpha() is False and caracter not in ".,?! ": # trebuie sa fie numar sau litera sau acele semne de punctuatie raise ValueError print("Datele de intrare corespund restrictiilor impuse") def poezie(lista_versuri): # functia de rezolvare for vers_cu_punctuatii in lista_versuri: vers_fara_punctuatii = "" # creem versiunea de vers fara punctuatii for caracter in vers_cu_punctuatii: if caracter not in ".,?!": # adaugam caracterul in acest sir doar daca nu e semn de punctuatie vers_fara_punctuatii += caracter ultimul_caracter = vers_cu_punctuatii[len(vers_cu_punctuatii)-1] # ultimul caracter poate fi si semn de punctuatie deci il tratam separat if ultimul_caracter in ".,?!": vers_fara_punctuatii += ultimul_caracter print(vers_fara_punctuatii) # afisam versul fara semne de punctuatie if __name__ == '__main__': # din cauza datelor de intrare pot aparea 2 tipuri de erori, valueError sau IndexError pe care le tratam try: versuri = [] # lista de versuri numar_versuri = int(input("Introduceți numărul de versuri: ")) # citirea numarului de versuri for index in range(numar_versuri): vers = input(f"Introduceți versul {index + 1}: ").strip() # citirea fiecarui vers pe rand versuri.append(vers) # adaugarea acestuia in lista validare(numar_versuri, versuri) # apelul functiei de validare poezie(versuri) # apelul functiei de rezolvare except ValueError: print("Datele de intrare nu corespund restrictiilor impuse") except IndexError: print("Datele de intrare nu corespund restrictiilor impuse") </syntaxhighlight>
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width