From the course: Python Data Structures and Algorithms

Solution: Read and display a maze from a text file - Python Tutorial

From the course: Python Data Structures and Algorithms

Solution: Read and display a maze from a text file

(upbeat music) - [Instuctor] So, the solution is fairly straight forward for this, we're going to create a maze again, and it's going to be equal to read_maze, and this time we're going to use a different maze. Mazes, forward slash challenge_maze and pie charm suggest the correct answer, and then exactly the same. So, for row in maze, print row. Okay, now just one thing I'm going to do just to separate them, I'm going to do print I'm going to do backslash in that Princeton new line, and then just a bunch of subtraction signs, just to give me a bit of a divide on my output and then a new line again. So, let's see what that looks like. So, you can see we've got the first one printed as before, but then we've got a divider and we've got the challenge_maze printed row by row as required. Okay, so that's how you read a maze from a text file into Python using the helper function that we provided called read_maze.

Contents