Python Forum
White spaces - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: White spaces (/thread-21653.html)



White spaces - kdiba - Oct-08-2019

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


RE: White spaces - Aurthor_King_of_the_Brittons - Oct-08-2019

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;