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

what is the lcd of 3/10an -4/15?
what two numbers can you multiply to get 576 but add to get 0
The development of nuclear power has provided electricity for less money, but at a cost. What may be considered a "cost" of nuclear power? A. Large amounts of
Are whales abiotic or biotic or both
An 8- pound bag of apples costs $17.50.What is the unit price?
atoms differ in their affinity for neutrons, a property called electronegativity. true/false
Help help help help thanks lol
atoms differ in their affinity for neutrons, a property called electronegativity. true/false
the rust on a rusty bicycle is an example of a
Yugoslavia is now made up of _______ and Montengro.. Serbia Croatia Albania