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

Gina was earning $10 per hour. THen she recieved a 10% pay increase. Next month, her pay rate will decrease by 10%. What will Gina's pay rate be next month? a.
Sea turtles dig holes and lay eggs in the sand at night, covering the holes to protect the eggs from the sun and predators. Which identifies the beginning of an
why does antibiotics cause cancer cells
state the additive property of zero, and provide an example using any other number
x²-3x=0 Solve by factoring I know that x=0,3, but how do you get that from x(x-3)=0?
y-0.45=-2.9 need assistance
Why was John Locke so important to the Enlightenment period in US history?
frogs produce a huge number of gametes at one time - why do you think this is ( hint: finding Nemo?
Why did the Japanese people support the aggressive actions of the military?
0.39 is 15% of what number