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 assignment by congress of congressional seats after each census is called
What does not describe a cause of the Spanish-American war in 1898
How do you find an equation for a scatter plot?
In the story the Lord of the flies by William golding would the events in the story still have happened if there had been adults on the island instead of just k
HELP QUICK PLEASE!!!!! What is the simplified form of the following expression? (4th root of a5b2c4) - 7ac (4th root of ab2)
HELP ASAP I'M TIMED!!! The measures of the angles of any triangle always add up to 180˚. Polygon XYZ is a triangle. Which of the following is valid base on dedu
Find the 18th arithmetic sequence when a1=-4 and d=6
A Web music store offers two versions of a popular song. The size of the standard version is 2.4 megabytes (MB). The size of the high-quality version is 4.8
What would be the consequence of deleting the late t4 genes?
A gene ___________ is a specific location of a gene along a chromosome