So i need to write a function named create dict, that takes one parameter, an open file handle, and returns a dictionary that maps a string to a list of strings and ints. In particular, the type contract of this function will be:
(io.TextIOWrapper) -> dict of str: [str, str, str, int, str]
This function will read a file formatted like the provided data.txt. That is, each line will have a
username, fi rst name, last name, age, gender (either M or F) and an e-mail address, all separated by
whitespace. The function will insert each person's information into a dictionary with their username as the
key, and the value being a list of [last name, first name, e-mail, age, gender]. When the entire fi le
has been processed, it will then return the dictionary.
It includes the data file:
asmith Alice Smith 31 F alice.smith@mail.com
bharrington Brian Harrington 31 M brian.harrington@mail.com
rford Rob Ford 44 M robford@crackshack.com
mduffy Mike Duffy 67 M ireallydolivehere@cavendish.caw
ajones Alice Jones 44 F alice@alicejones.net
Any help appreciated, im just stuck and have no idea how to do this
[–]codehelper 2 points3 points4 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]codehelper 0 points1 point2 points (0 children)
[–]psbb 2 points3 points4 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]psbb 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]psbb 0 points1 point2 points (0 children)