Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was just showing you what the data structure to store your text might look like. In practice there are a number of ways to do it, but you should be guided by what'll make it easiest to get your data out. In other words, you might be able to make it work with a list of lists, but you're trying to cut 'across' the list, rather than with it. So with your existing list:

list = [ ['Hello World', 'Hello World'], ['Hello Universe', ...], ... ]

you'll need to display the first item of each on one row, then the second, and so on, which is a hassle.

Another way might be to pregenerate your list of lists with blank items (assuming that you know how many different strings you have and how many tries they get) then track the current row and column number. If they enter it successfully then your current row increments by one. If they choose a different one, then increment your column and reset

But you seem to be overly focused on the details of your implementation (ie. rows and columns), rather than the simplest way to achieve what you want. A third way would be to have each series on a separate page, so you only need to track the current string. Once they're ready, they can click a button to get to the next one/enter a new string.

A fourth way - don't use a table, use <divs> with a set width and display-inline. Each <div> has the previous entries separated by line breaks, with a form for the final one. With this sort of structure you can process each list in turn, without having to worry about indexing.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: