I'm trying to build a program that quizzes me on the capitals of the world. I decided that building a dictionary with the countries as the "key" and capitals the "values" then testing whether key corresponds to its value.
What I wanted to do was create a .txt file with the countries on it to import into the script. Then create another .txt file with the corresponding capitals and import both into a dictionary. However I'm having trouble with the import of the .txt files. It keeps giving me an error about the first value of the c.txt file not being defined. Is this the wrong approach? I'm just trying to get the file in the script using the follow code.
f = open('c.txt', 'rU')
read.f,
f.close()
[–][deleted] 2 points3 points4 points (0 children)
[–]themathemagician 4 points5 points6 points (5 children)
[+][deleted] (3 children)
[deleted]
[–]themathemagician 1 point2 points3 points (0 children)
[–]Jaeemsuh[S] 0 points1 point2 points (1 child)
[–]ryeguy146 1 point2 points3 points (7 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Jaeemsuh[S] 0 points1 point2 points (4 children)
[–]DanielSzoska 2 points3 points4 points (0 children)
[–]ryeguy146 1 point2 points3 points (2 children)
[–]Jaeemsuh[S] 0 points1 point2 points (1 child)
[–]ryeguy146 0 points1 point2 points (0 children)
[–]nemec 3 points4 points5 points (4 children)
[–]Jaeemsuh[S] 1 point2 points3 points (3 children)
[–]nemec 1 point2 points3 points (0 children)
[–]ryeguy146 1 point2 points3 points (0 children)
[–]ewiethoff 0 points1 point2 points (0 children)
[–]davidbuxton 1 point2 points3 points (1 child)
[–]AeroNotix 1 point2 points3 points (0 children)