Python Forum
Need help with checkio problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with checkio problem
#1
Ok, so the problem is to solve this question...Can anyone help ?

In a given text you need to sum the numbers. Only separated numbers should be counted. If a number is part of a word it shouldn't be counted.

The text consists from numbers, spaces and English letters

Input: A string.

Output: An int.

Help please!
Reply
#2
what have you tried?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
You need to provide a sample of the input text you need to analyze and at least show some effort on your part at coming up with a solution. HINT: Python has a built-in function called split() that will break strings apart when there's a space between words and return a list. There is also a function called isnumeric() which I'm sure will be useful to you.
Multicast likes this post
"So, brave knights, if you do doubt your courage or your strength, come no further, for death awaits you all with nasty, big, pointy teeth!" - Tim the Enchanter
Reply
#4
Break the problem into parts. The problem says you need to sum numbers that appear in text. It says only separated numbers should be counted.

1. What does "separated numbers" mean?
2. How can you find the separated numbers?
3. How can you compute the sum of the separated numbers?

Solve 1 first. That should be easy and it affects how you will approach the solution for part 2. Part 2 must be competed before you perform part 3.

So what is your answer to part 1?
Reply
#5
(Jul-22-2020, 06:03 PM)deanhystad Wrote: Break the problem into parts. The problem says you need to sum numbers that appear in text. It says only separated numbers should be counted.

1. What does "separated numbers" mean?
2. How can you find the separated numbers?
3. How can you compute the sum of the separated numbers?

Solve 1 first. That should be easy and it affects how you will approach the solution for part 2. Part 2 must be competed before you perform part 3.

So what is your answer to part 1?
thanks. I think we need to split the string and if the string is a number, then return result . Else not.
Reply
#6
Code. Where is the code?

And wasn't this a homework question posted back in July? Isn't it a bit late now?
Reply
#7
(Jul-22-2020, 03:59 PM)Marbelous Wrote: You need to provide a sample of the input text you need to analyze and at least show some effort on your part at coming up with a solution. HINT: Python has a built-in function called split() that will break strings apart when there's a space between words and return a list. There is also a function called isnumeric() which I'm sure will be useful to you.

Thanks for the isnumeric() hint!!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020