1
The following I have an input file(.txt) which is the following:
9
branco
preto
azul
verde
rosa
amarelo
vermelho
cinza
lilas
OHLEMREVU
BBRANCOZA
SRAMSUPAO
AABAPOTZZ
LNZROERNU
IUIEPDOII
LOLLORACA
ITMOTERPP
LIEAZVYUU
and from this I want to iterate only on the part
OHLEMREVU
BBRANCOZA
SRAMSUPAO
AABAPOTZZ
LNZROERNU
IUIEPDOII
LOLLORACA
ITMOTERPP
LIEAZVYUU
for this I thought I used a for but whenever I do this it "selects" all lines" instead of the intended part. Someone help me?
Hello, welcome to SOPT. Your question is not clear. Are the words in the file all together, or one on each line? How you made your code (edit the question and post the relevant excerpt). If not yet, do the [tour] and mainly read [Ask].
– Luiz Vieira
Either way, you’re gonna have to iterate line by line. It takes the value of the first (which I suppose is how many words are) and puts it in a list (with an if counter < number of the first line). If the IF condition has been reached, what comes next is your word search board. In short: take 1st line, convert to numeric. You take the following lines and increment a counter. for as long as the counter is less than or equal to the initial value, store in the word list, otherwise store on the board.
– Bacco
Yes, the file is as it is now (every word per line).
– Toshiyuki
Toshiyuki, it would be nice if you click [Edit] and add the code you tried in the post, it is easier for those who respond to use as a basis to locate the problem or propose solution..
– Bacco
Just one more question if I want in tuples(tuples) instead of lists as I would do?
– Toshiyuki
I’m still at the beginning but when I’m done doing the search function.
– Toshiyuki
@Toshiyuki posts that initial part in the question, so the staff can post an official answer. Thus, it solves this initial part, then when searching opens a separate question from the already solved code. The ideal here is always to divide the problem into small parts, and solve one at a time in each question, objectively. Click on [Edit] and put the code, even if it still doesn’t work as you want, and explain in more detail, then the chance of a legal answer increases, instead of us solving in the comments.
– Bacco
It would be nice if in the question you made it clear that these are crossword puzzles.
– Victor Stafusa