Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
White spaces
#1
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
Reply
#2
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; 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  identify not white pixels in bmp flash77 17 2,270 Nov-10-2023, 09:21 PM
Last Post: flash77
  including the white space parts in str.split() Skaperen 6 3,189 Jun-20-2019, 06:03 PM
Last Post: Skaperen
  replace white space with a string, is this pythonic? Skaperen 1 1,978 Jun-18-2019, 11:36 PM
Last Post: metulburr
  Because the emoji appears black and white at the exit ? nerd 3 5,518 Jan-28-2019, 11:34 PM
Last Post: nerd
  White Space Help JayMan 9 6,180 Dec-26-2017, 02:58 AM
Last Post: Skaperen
  Python interface only black and white........ Wilson 3 6,050 Jul-15-2017, 01:20 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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