Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print
#4
sorry, the extra curly braces were added by mistake - I already edited my answer when I saw them.
But anyway I misunderstood your goal ( I thought you want to print string), so just ignore it
It looks like you try to create variables dynamically, e.g. you want to assign the result of get_predictions(2005, 12) to predictions_2005 and parameters_2005
You should use use proper data structure instead
predictions = {}
parameters = {}

for year in range(2005, 2008):
    prediction, param = get_predictions(year, 12)
    predictions[year] = prediction
    parameters[year] = param
This way you will get a dict with predictions and dict with params.
predictions dict would look like {2005:<some value>, 2006:<some value>, 2007:<some value>}

Of course you can have single dict of dicts with both predictions and params in the neseted dicts
e.g. results dict would look like {2005:{'predictions':<some value>, 'params:<some value>}, 2006:{'predictions':<some value>, 'params:<some value>}, 2007:{'predictions':<some value>, 'params:<some value>}}
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
Print - by kdiba - Oct-11-2019, 11:12 AM
RE: Print - by buran - Oct-11-2019, 11:17 AM
RE: Print - by kdiba - Oct-11-2019, 11:28 AM
RE: Print - by buran - Oct-11-2019, 12:04 PM
RE: Print - by kdiba - Oct-11-2019, 12:17 PM
RE: Print - by buran - Oct-11-2019, 12:26 PM
RE: Print - by kdiba - Oct-11-2019, 12:28 PM
RE: Print - by buran - Oct-11-2019, 12:29 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020