> Program read TXT file (c:\\slo3.txt) > In this file there are two words per line separated by tab. > First word is foreign language and second word is proper translation, like > this: > > pivo beer > kruh bread > rdeca red > krompir potatoe > hisa house > cesta road > auto car > > (not even trying to mess with special characters for now, lol)
Do look at: http://www.joelonsoftware.com/articles/Unicode.html because the fact that you're dealing with foreign language means you want to get it right. If it were me, I'd just say that the input is UTF-8 encoded text, and always open up the file in utf-8 mode. myfile = open("slo3.txt", "r", encoding="utf8") and just know that we're working with Unicode from that point forward. > I was going to read content into dictionary, each pair as tuple but I gave > up, couldn't figure it out. Looks like it is working with the list so no > problem. > > Question 1: would be better to use dictionary, than list? It depends. If you're picking out a random entry, then having a dictionary in hand is not going to need the key lookup support that dictionaries give you. For the application you're describing right now, it doesn't sound like you need this yet. > Question 2: slo3.txt is just small sample for now and before I type in all > words, I would like to know is it better to use some other separator such as > coma or empty space instead of TAB? I found on the internet example for TAB > only, so this is what I'm using for now. TAB is a reasonable separator. You might also consider comma, as in Comma-Separated Values (CSV). If your data starts having more structure, then check back with folks on the tutor mailing list. There are richer formats you can use, but your program's description suggests that you probably don't need the complexity yet. > > I need help with two things. First one is simple, basic, but I couldn't > figure it out. If I want to print out 'Wrong,,,,' part in the same line next > to wrong answer, how do I do it? The print function puts a newline at the end. You can change this default behavior by providing an "end" keyword to it. The documentation mentions it here: https://docs.python.org/3/library/functions.html#print Small test program to demonstrate: ################ print("Hello ", end="") print("world ") ################ > Now, big, huge help request. > I would like to make it easy on my wife :-) instead of her needing to type > in answer I would like that she could choose (click on) multiple choice. Say > she get 4 or 5 possible answers and one of them is correct. Then she need to > click on correct answer... > > What do I need to do? I understand there will be some graphic/windows things > involved. I don't have any additional packages or libraries installed, nor > do I know what/how do do it. Complete noob.... How about printing them with numbers, so that entry is just a number rather than the typed word? You can put a graphical user interface on the program, though it does take a bit more effort to get it to work. Look into "Tkinter", which is a library for producing graphical user interfaces: https://wiki.python.org/moin/TkInter Another option might be to turn your program into a web site, so that the interface is the web browser, which everyone is getting used to these days. But this, too, is also... involved. :P _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor