Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def search_it_all(profilesx, xname):
- f = open(profilesx, 'r')
- fileread = f.readlines()
- for line in fileread:
- line = line.replace("\n", "")
- x= line.split(",")
- name = x[0]
- age = x[1]
- gender = x[2]
- location = x[3]
- activities = x[4:]
- result.append(create_profile(name,age,gender,location,activities))
- for x in range (0, len(result)):
- if (result[x])["name"] == xname:
- print result[x]
- return result
- f.close()
- #Kör sedan följande i tolken:
- search_it_all("profilesx.txt", "mj") #och får följande felmeddelande:
- Traceback (most recent call last):
- File "<pyshell#17>", line 1, in <module>
- search_it_all("profilesx.txt", "mj")
- File "E:\Plugg\Programmering grundkurs\Projekt\functions.py", line 66, in search_it_all
- if (result[x])["name"] == xname:
- TypeError: 'NoneType' object is not subscriptable
- #Vad kan vara fel? :S
Add Comment
Please, Sign In to add comment