evgeniy Posted October 17, 2011 Report Share Posted October 17, 2011 (edited) elem, kao sto deskripshn kaze, treba mi pomoc oko neceg jednostavnog. ako iko zna pajton, resice ovu glupost za ~2ms. ja ne. samo me zanima da li je ikako izvodljivo odraditi ovo sto sam zamislio listama. guglao sam kako da konvertujem stringove iz liste u integer, ali ne nadjoh resenje. je l' moguce uopste izvesti to? edit: n.append( (n[0] + 1) ) ce svaki put dodati vrednost 1 listi, eto jednog zajeba. meh, pametniji sam ujutru, odoh u krevet. Edited October 17, 2011 by digrejzo Quote Link to comment Share on other sites More sharing options...
voodoo_ Posted October 18, 2011 Report Share Posted October 18, 2011 Ne razumem šta si tačno rekao, ali ako ti treba ta konverzija stringa u int, to se radi prostim int(tekst) Quote Link to comment Share on other sites More sharing options...
reiser Posted October 18, 2011 Report Share Posted October 18, 2011 (edited) Znaci python se koristi u bibliotekama! Nemas potrebe da ponavljas pokusaj = raw_input("> ") vise puta. Code reuse ftw. sifra = list(sifra) ti je nepotrebna linija, i generalno ceo taj rad sa listama. U n (int) mozes da cuvas do kog indexa u stringu se stiglo pomocu "hint" i taj deo stringa prikazujes kao sifra[0:n] \n je escape character i prevodi se kao line break, dakle dve print() su ekvivalentne jednoj "No way jose.\nProbaj opet." def juzerinput(): print "'hint' za jos jedno slovo" print "'pomoc' za celu rec" n = 0 sifra = "KlanRUR" juzerinput() print sifra pokusaj = "" while True: pokusaj = raw_input("> ") if pokusaj == sifra: print "Tacno" break elif pokusaj == "hint": if n < len(sifra): n+=1 print "Rec je:", sifra[0:n] else: print "Pa dokle vise?" elif pokusaj == "pomoc": print "No way Jose.\nProbaj opet." elif pokusaj == "exit": print "Taj rad." break else: print "Wrooooong." Edited October 18, 2011 by reiser Quote Link to comment Share on other sites More sharing options...
evgeniy Posted October 18, 2011 Author Report Share Posted October 18, 2011 dzizs krajst koji sam nob, skroz sam zaboravio string slice. muchas gracias =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.