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

5/8 as a decimal and as a percent
A grant to an inventor to make, use, or sell an invention is called a
The Peace Corps was started by President
What are the angles of rotation for a 15 gon
Which artistic work did Michelangelo contribute to the Renaissance?
Which of the following pairs of numbers contains like fractions? A. 3/2 & 2/3 B. 5/6 & 10/12 C. 3 1/2 & 4 4/4 D. 6/7 & 1 5/7
How old is barack obama?
In a parking garage,the number of SUVs is 40% greater than the number of non-SUVs.Gina counted 98 SUVs in the parking garage .How many vehicles were parked in t
You run around the perimeter of the baseball field at a rate of 9 feet per second. How long does it take you to run around the baseball field?
charlottes family bought a 2-pound block of cheese there is 1/4 of the block of cheese left how many ounces of cheese has charlottes family eaten