removing-whitespace

Removing trailing whitespace for a tic tac toe board in python

Removing trailing whitespace for a tic tac toe board in python Question: I am trying to resolve the error as highlighted in the picture below. I am able to print a tic-tac-toe board but the trailing whitespace affects the test case. I am not better yet at using strings to represent a list of numbers. …

Total answers: 2

Unsure how to remove whitespace from strings

Unsure how to remove whitespace from strings Question: current_price = int(input()) last_months_price = int(input()) print("This house is $" + str(current_price), ‘.’, "The change is $" + str(current_price – last_months_price) + " since last month.") print("The estimated monthly mortgage is ${:.2f}".format((current_price * 0.051) / 12), ‘.’) This produces: This house is $200000 . The change is …

Total answers: 3

Remove all whitespace in a string

Remove all whitespace in a string Question: I want to eliminate all the whitespace from a string, on both ends, and in between words. I have this Python code: def my_handle(self): sentence = ‘ hello apple ‘ sentence.strip() But that only eliminates the whitespace on both sides of the string. How do I remove all …

Total answers: 13

Substitute multiple whitespace with single whitespace in Python

Substitute multiple whitespace with single whitespace in Python Question: I have this string: mystring = ‘Here is some text I wrote ‘ How can I substitute the double, triple (…) whitespace chracters with a single space, so that I get: mystring = ‘Here is some text I wrote’ Asked By: creativz || Source Answers: A …

Total answers: 3