subject

Reading input from file, instead of hard-coding values in your code or getting them from user input, can speed up your workflow and allow you to write modular code. In this lab, you will write a function read_configuration(), which will take a filename as its input and return a list, where every line from the file is a list, which contains each whitespace-separated value as its element.
For example, below are the contents of a file is called board1.txt:
X O .
X O .
X . .
After processing this file, the function should produce the following:
>>> read_configuration("board1.txt")
[['X', 'O', '.'], ['X', 'O', '.'], ['X', '.', '.']]
Note that you can visualize the returned list as follows to see how it maps to the input file
[['x', 'o', '.'],
['x', 'o', '],
['x', '.', ']]
Hint: Remember that split() is a really helpful function. Also, you can get a sense of how to approach file processing by following along.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 18:00
What is stored in str after the following code executes? string str = "computer science"; int i = 0; while (i < 8) { if (str.indexof("m") < i) { str = str.substring(0, 2) + str; } i += 2; } computer science cocomputer science cococomputer science cocococomputer science computer scienceco
Answers: 3
question
Computers and Technology, 22.06.2019 03:00
How can i clip a picture to a question on the computer?
Answers: 1
question
Computers and Technology, 22.06.2019 15:10
David is in week 3 of his current ashford course and has a paper due by monday night at midnight. he has finished everything but the concluding paragraph. as he boots up his computer to work on it, he sees a flash across the screen and then the screen goes black. he begins to panic as he tries desperately to turn the laptop back on. david should have saved his work on what kind of portable device?
Answers: 2
question
Computers and Technology, 22.06.2019 16:10
When copying and pasting text, the first step is move your cursor type the text select the copy command select the paste command
Answers: 2
You know the right answer?
Reading input from file, instead of hard-coding values in your code or getting them from user input,...
Questions
question
Mathematics, 17.03.2020 19:59
Questions on the website: 13722367