GAMECORE Posted January 2, 2018 Posted January 2, 2018 Task: Scrieți un program ( folosind funcții ) Care solicită utilizatorului un șir alcatuit din mai multe cuvinte. Să se afișeze pe ecran același șir, imprimând cuvintele de la coada la cap. Exemplu: Daca introducem șirul: Ana are mere Rezultatul afișat pe ecran va fi: mere are Ana Sursa: Spoiler def function(word): word = word.split(" ") word.reverse() return " ".join(word) if __name__ == "__main__": word = input("Introduceti cuvantul: ") list_of_words = function(word) for i in list_of_words: print(i,end="") Funcție scrisă într-o linie de cod: Spoiler def function(word): return " ".join(word.split()[::-1]) 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now