Page 121 -
P. 121
files and exceptions
Adjust your code to use the extra logic technique demonstrated on the previous page to deal
with lines that don’t contain a colon character.
What condition needs to go here?
data = open('sketch.txt')
for each_line in data:
if
(role, line_spoken) = each_line.split(':', 1)
print(role, end='')
print(' said: ', end='')
print(line_spoken, end='')
data.close()
Can you think of any potential problems with this technique?
Grab your pencil and write down any issues you might have with
this approach in the space provided below:
you are here 4 85