Sample from the file :
Employer: {
name:"Jack M", age:"213", phone:"11221"
}
Guest: {
name:"Alex K", age:"203", phone:"11111"
}
From that file, i need to export all the Guest names. Tried that:
file = "data.txt"
nameslist=[]
with open(file, "r") as f:
i = f.read()
check = i.find('Guest: {')
while check != -1:
i = i.replace('Guest: {', '\n')
i = i.split('\n')
i = i[1]
i = i.replace('name:"', '\n')
i = i.split('\n')
i = i.replace('",' '\n')
i = i.split('\n')
global nameslist
nameslist.append(i[0])
i = i[1]
check = i.find('Guest: {')
print(nameslist)
always have an error like that:
File "asd.py", line 11
i = i.split('\n')
^
TabError: inconsistent use of tabs and spaces in indentation
What i am doing wrong ?