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 20:30
To display data in a certain manner like alphabetical order is called
Answers: 1
question
Computers and Technology, 22.06.2019 10:30
This first part of the film shows the early history of motion pictures. how accurate do you think the portrayal of the early motion picture industry is? why? is historical accuracy important in films and theatre productions? explain. in the scene where don is going to the party (starting at time code 14: 51), we see a street scene as he first rides with cosmo and then with kathy. what aspects did the filmmaker include to make the scene look and feel like don, cosmo, and kathy are riding in a car on a street? think about elements such as scenery, sound, props, lighting, and so on. a "talkie" picture is shown starting around time code 21: 15. how does the audience in the film react to the "talkie"? what influence do audiences have on film and theatre performances? how do film and theatre actors influence audiences? in the musical scene with cosmo (starting at time code 27: 00), how does the actor use props? what is the result? do you think the use of props effectively fulfilled the artistic vision for this musical number? why or why not?
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
Hey so i was just trying out some game hacks so i took a paste from online and built it in my visual studio and then suddenly my computer was working or clicking on stuff on its own am i hacked?
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
How often does colleges update the cost of attendance on their website? . a)every two years b) every four years c) every year d) every semester
Answers: 1
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
Chemistry, 26.09.2021 09:20
question
English, 26.09.2021 09:20
question
Mathematics, 26.09.2021 09:20
question
Mathematics, 26.09.2021 09:20
question
Social Studies, 26.09.2021 09:20