Even though the variable is having the 1st dictionary value for the key name from the JSON file, while storing that value to a list I am getting output as None. This seems to be a strange.. Am I missing something. Could you please help
Code:
import os
import shutil
import json
MainDir = "F:/Protocols/20180207-Iteration/"
os.chdir(MainDir)
MainDir = os.getcwd()
# print(MainDir)
#Load the JSON data to a file
with open("F:/Protocols/20180207-Iteration/rout.json",'r',encoding='utf-8') as f:
json_file = json.load(f)
#To avoid appending delete the file all_iteration.txt if it exists
if os.path.exists("all_iteration.txt"):
os.remove("all_iteration.txt")
#Create all_iteration.txt which will store the foldernames of the particular Iteration inside the Iteration folder
Path_List = []
for values in json_file['value']:
Folder_Names = values['name']
Indivisuals = str(Folder_Names)
Path_List = list(Path_List.append(Indivisuals))
print(Path_List)
print(Path_List)
Log:
E:\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 51533 --file C:/Users/SPAR/PycharmProjects/Sample/PATH_FINDER.py
pydev debugger: process 10528 is connecting
Connected to pydev debugger (build 173.4301.16)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\pydevd.py", line 1668, in <module>
main()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\pydevd.py", line 1662, in main
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\pydevd.py", line 1072, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.3.3\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/SPAR/PycharmProjects/Sample/PATH_FINDER.py", line 23, in <module>
Path_List = list(Path_List.append(Indivisuals))
TypeError: 'NoneType' object is not iterable
Process finished with exit code 1