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 10.75 rounded to the nearest tenth?
Need help with the last two
What differentiates atoms from elements?
which is not used to describe a population of grizzly bears in canada a) demographic history b) geographic distribution c) overall growth rate d)population
Drag and drop the answer into the box to match each point to its coordinates.
In the years that followed, i failed her many times, each time asserting my will, my right to fall short of expectations. i didn't get straight as. i didn't bec
Solve for x and show work (6x-18)
rhe subsript in a chemical formula refers to the ___.
What is 10.75 rounded to the nearest tenth?
true or false covalent bonds take place between 2 non metal elements