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 most caused the growing emphasis on male masculinity?
continents crossed by the tropic of capricorn are:
How many neutrons does element X have if it’s atomic number is 21 and it’s mass number is 75
PLEASE HELP ASAP!!! CORRECT ANSWER ONLY PLEASE!!! What is (98 - 2n) equal to?
PLEASE PLEASE HELP Why did the British government impose taxes on the American colonies? A. for administrative purposes B. to pay for the voyages of the Bri
Exponential form of log bM= y
Which of the following statements is true?
BRAINLIEST ANSWER Susan is hiking at an elevation of 20 feet above sea level. Who is located the same distance from sea level but in the opposite direction
Cigarette smoking by a pregnant woman can influence infant development in which time frames
which sentence best describes a factor that motivated american colonists to declare their independence from the british