bennyanderson7704 bennyanderson7704
  • 22-11-2021
  • Computers and Technology
contestada

Assume you have assigned x the string value of "125,000" (i.e., x = "125,000"). Can you find a string method that tests if x only contains digits?

Respuesta :

holmtheditto
holmtheditto holmtheditto
  • 22-11-2021

Answer:

x = x.replace(',', '')

print(x.isdigit())

Explanation:

isdigit() is a built-in checking method which checks if a string contains all digit values or not. Since x contains a ',' it has to be removed and since strings are immutable, i create a new string without the comma. Then I check if it is a digit, in which case it is true.

Answer Link

Otras preguntas

Which wife of England's King Henry VIII produced a male heir?
What can I do to lose belly fat? I eat normally, not healthy not unhealthy, exercise everyday and nothing, no change.
I need all of these please help
Dianne's profit from selling magazine subscriptions varies directly with the number of subscriptions sold. Dianne made $30 from selling 24 subscriptions. Which
Help me please (15 points)
_____1. The price paid for the use of someone else’s property.
What do the signers pledge to do at the end of the Declaration of independence?
What is the extra amount that Mary would pay for apples under a monopoly instead of a perfect competition
Misha measured a distance of 60 feet from her kitchen to her bedroom. What is the equivalent number of meters (rounded to the nearest hundredth)? Unit of Length
A bottle holds 3 pints of lemonade. How much is this in fluid ounces?