Hi I am using the below code to return some json from a url and it returns the results as a list just how I want, however I want to add a string to each of the returned results.
Printing n in a for loop works but I dont know where to add the string I want to add to the result, everything I have tried throws errors about mixing stings with lists. I have read about arrays and can add data to the array and show onlly certain results but am not sure where to start with adding data to the result.
for example.
I get
Result1
Result2
Result3,
etc,
however I want to return
String Result1
String Result2
String Result3.
the string will be constant but the result will be what has been returned.
import urllib.request as request
import json
with request.urlopen('https://jsondatalist') as response:
if response.getcode() == 200:
source = response.read()
data = json.loads(source)
for n in (data):
print (n)
else:
print('An error occured while attempting to retrieve data from source')