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 percent of carbon-14 remaining after two half-lives?
You want to install wall–to–wall carpeting in your room. The room is 10 feet by 14 feet. What is the actual cost for carpeting if the carpeting costs $18.89 per
is anorexia a real disease?
Supply four reasons why the tuli breed would be superior to exotic breeds?
if 3.5 liters of gas in a container holds a volume of 50 liters at a temperature of 400k what is the pressure inside the container in stm
How does the destruction of books lead to more happiness and equality, according to Beatty?
What is the theme of William Shakespeare’s Sonnet 116? [a]steadfastness of love [b]immortality of art [c]power of time and nature [d]uncertainty of life
Please.help its so confusing..
When you are creating Internet ads, what is something you should try to avoid? Question 12 options: Advertising on social networking sites Irritating or annoyin
Hormones control the growth changes that result from tropisms. true or false