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

the former mission is now called the
Humans conduct _____. external fertilization internal fertilization conjugation pollination
Can someone please help me solve this problem?
Bashar went bowling with $25 to spend. He rented shoes for $5.25 and paid $4.00 for each game. What was the greatest number of games Bashar could have played?
_______________________ is the process of cell modification from a generalized cell to one that performs a specific task.
A caterpillar represents which stage in the life cycle of an insect? A. pupa B. larva C. adult D. egg
What occurs when a rock is broken into smaller pieces without a change in the rock's mineral composition?
Which factor is not used to define biomes? a. plant structures b. leaf type c. historical similarities d. climate
why did colonists care about having representations
The product of 9 and a number is 12 less than three times that number. What is the number?