[Tutor] Fwd: Need help with find error
Danny Yoo
dyoo at hashcollision.org
Tue Feb 17 21:28:47 CET 2015
This was mailed just to me by accident. Forwarding to tutor.
Apologies for not forwarding this ten days ago: I missed it.
---------- Forwarded message ----------
From: Андрей Пугачев <pugachov.andrey at gmail.com>
Date: Sat, Feb 7, 2015 at 12:27 AM
Subject: Re: [Tutor] Need help with find error
To: Danny Yoo <dyoo at hashcollision.org>
Sorry for my absense, but you want to say, that loop in code isn't
working? (in main()-function)
When category is empty code must print 2 last rows, but I have error....
I learn python book M. Dawson and this exercise from his book.
I add original working files, where points count as score +=1 and all works.
But if I add some points to each question code don't work.
I can't understand it/
2015-02-04 20:24 GMT+02:00 Danny Yoo <dyoo at hashcollision.org>:
>
> As a revision of my initial question, when we look at next_block(),
> it's documented as follows:
>
> ############################################
> def next_block(the_file):
> """Return the next block of data from the trivia file."""
> ....
> ############################################
>
> What if there are no more blocks in the file? What should happen then?
>
> Let's say that we do a test, where we pass in the empty file to next_block().
>
> ######################
> from io import StringIO
> x = next_block(StringIO(''))
> ######################
>
> What do you want to happen in this situation?
>
> ---
>
> As a side note: if you have control over the data format, you might
> want to consider using JSON rather than a line-based format. If you
> use JSON, this takes care of a few issues that you are working around
> now.
>
> For example, you can reuse the newline escapes rather than define your
> own convention. Also, rather than read a stream of records, where you
> have to deal with the end of the file, you might just read one JSON
> object that represents your whole trivia file, which will simplify
> your program's logic.
>
> See: https://docs.python.org/2/library/json.html and use your favorite
> web search engine for 'json python tutorial', and you should be able
> to find some useful information. If you have questions, please feel
> free to ask.
-------------- next part --------------
An Episode You Can't Refuse
On the Run With a Mammal
Let's say you turn state's evidence and need to "get on the lamb." If you wait /too long, what will happen?
You'll end up on the sheep
You'll end up on the cow
You'll end up on the goat
You'll end up on the emu
1
A lamb is just a young sheep.
The Godfather Will Get Down With You Now
Let's say you have an audience with the Godfather of Soul. How would it be /smart to address him?
Mr. Richard
Mr. Domino
Mr. Brown
Mr. Checker
3
James Brown is the Godfather of Soul.
That's Gonna Cost Ya
If you paid the Mob protection money in rupees, what business would you most /likely be insuring?
Your tulip farm in Holland
Your curry powder factory in India
Your vodka distillery in Russian
Your army knife warehouse in Switzerland
2
The Rupee is the standard monetary unit of India.
Keeping It the Family
If your mother's father's sister's son was in "The Family," how are you /related to the mob?
By your first cousin once removed
By your first cousin twice removed
By your second cousin once removed
By your second cousin twice removed
1
Your mother's father's sister is her aunt -- and her son is your /mother's first cousin. Since you and your mother are exactly one generation /apart, her first cousin is your first cousin once removed.
A Maid Man
If you were to literally launder your money, but didn't want the green in your /bills to run, what temperature should you use?
Hot
Warm
Tepid
Cold
4
According to my detergent bottle, cold is best for colors that might run.
More information about the Tutor
mailing list