Source: https://docs.google.com/presentation/d/14EF42i3A8RrRnhmocf0F5s40H7aht5Pl7UVHh3PEPzs/edit
Working with files
Writing to a file
- Open file in writing mode (‘w’ or ‘a’)
- Use
.write
method and pass a string that you want to write to a file
Note: must cast to string when writing to file
List Comprehension, Strings
List Comprehension Came From Math
It is Python’s way of implementing a well-known notation for sets as used by mathematicians.
An elegant way to create lists in Python
Faster than a regular loop with append
Convert C to F