Python Forum
Remove a space between a string and variable in print
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove a space between a string and variable in print
#1
Hello, i was wondering on how can i remove the space between the variable color and a string ", I prefer red"
color = str.lower(input ("Please enter your favorite color "))
print ("I don't like", color,", I prefer red")
the output of the code when purple is entered:
Output:
Please enter your favorite color purple I don't like purple , I prefer red
I hope to remove the space between the color and comma so it'll appear as
Quote:I don't like purple, I prefer red
Reply


Messages In This Thread
Remove a space between a string and variable in print - by sie - Jul-27-2022, 05:58 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  remove gilberishs from a "string" kucingkembar 2 365 Mar-15-2024, 08:51 AM
Last Post: kucingkembar
  Replacing String Variable with a new String Name kevv11 2 875 Jul-29-2023, 12:03 PM
Last Post: snippsat
  Print variable without '' and spaces arnonim 1 778 Jan-30-2023, 05:23 PM
Last Post: deanhystad
  Need help on how to include single quotes on data of variable string hani_hms 5 2,271 Jan-10-2023, 11:26 AM
Last Post: codinglearner
  Problem with print variable in print.cell (fpdf) muconi 0 711 Dec-25-2022, 02:24 PM
Last Post: muconi
  python r string for variable mg24 3 3,122 Oct-28-2022, 04:19 AM
Last Post: deanhystad
Smile please help me remove error for string.strip() jamie_01 3 1,301 Oct-14-2022, 07:48 AM
Last Post: Pedroski55
  USE string data as a variable NAME rokorps 1 1,038 Sep-30-2022, 01:08 PM
Last Post: deanhystad
  Removing Space between variable and string in Python coder_sw99 6 6,519 Aug-23-2022, 01:15 PM
Last Post: louries
  Split string using variable found in a list japo85 2 1,392 Jul-11-2022, 08:52 AM
Last Post: japo85

Forum Jump:

User Panel Messages

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