Python Forum

Full Version: White spaces
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I need your help for this :
input :
n=2005;
while (n!=2008) :
    print("prediction_",n,",","parameters_",n,"=get_predictions_each_year",(n,12));
    n=n+1;
output:
Output:
prediction_ 2005 , parameters_ 2005 =get_predictions_each_year (2005, 12) prediction_ 2006 , parameters_ 2006 =get_predictions_each_year (2006, 12) prediction_ 2007 , parameters_ 2007 =get_predictions_each_year (2007, 12)
The output above is correct but I'm trying to remove some white spaces.

I would like an output like :
Output:
prediction_ 2005, parameters_2005 =get_predictions_each_year(2005, 12) prediction_ 2006, parameters_2006 =get_predictions_each_year(2006, 12) prediction_ 2007, parameters_2007 =get_predictions_each_year(2007, 12)
Thank you in advance for your help
Use "sep" as follows to eliminate all spaces and then add spaces where you want them inside the quotes.

    n=2005;
    while (n!=2008) :
        print("prediction_",n,", ","parameters_",n, " =get_predictions_each_year",(n,12), sep='');
        n=n+1;