Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Zadatak 06

# zadatak od korisnika prihvaća string i zatim, koristeći uređene n-torke 
# ispisuje ga tako da znakove u njemu presloži po abecedi
# napomena: prije pokretanja programa unijeti string u STDIN

# unos stringa
print('Unesi tekst:')
tekst = str(input(''))
print(tekst)
print('----------')

# kreiranje liste n-torki
slova = []
for t in tekst:
    slova.append(tuple(t))
print(slova)
print('----------')

# sortiranje slova
slova.sort()
print(slova)
print('----------')

# kreiranje novog stringa
novi_tekst = ''
for s in slova:
    novi_tekst = novi_tekst + s[0]
print(novi_tekst)

    

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.