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

An implied power is one that
European dominance in the nineteenth and twentieth centuries was aided by 1) Nationalism 2)Socialism 3)Patriotism 4)Multiculturalism, as people had a common b
Which evidence from the text best supports the idea that Macbeth had decided to stop being unsure and will take action
Jean mandler argues that early categorizations are best described as _____ categorization. that is, the categorizations are based on similar features of objects
If h(x) = −4x − 10, find h(−5).
Kite wxyz has a short diagonal of xz and a long diagonal of wy. The diagonals intersect at point v. The length of xz=8 cm and the measure of xyv is 30 degrees.
What's up dog? Because my buddies asked the same question and it was never answered.
Explain two differences between prescription drugs and over-the-counter (OTC) drugs. Also, explain how te FDA regulates OTC drugs.
Snow leopard, cheetah, puma, jaquar, panther, tiger, and leopard are all examples of _______.
Why are ocean currents important?