Created
December 28, 2019 15:50
-
-
Save Bundi-py/84d692caf19fbd8df6d782528366dcae to your computer and use it in GitHub Desktop.
Napiši funkciju koja određuje da li je lista brojeva koje je uneo korisnik sortirana (po rastućem ili opadajućem nizu, svejedno) ili je nasumična. Funkcija treba da dâ rezultat True ukoliko je lista već sortirana pri unosu, a u suprotnom False.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def provera(): | |
if all(lista[i] <= lista[i+1] for i in range(len(lista)-1)): | |
return True | |
elif all(lista[i] >= lista[i+1] for i in range(len(lista)-1)): | |
return True | |
else: | |
return False | |
print(provera()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment