Write a program that checks the string s for the values
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Write a program that checks the string s for the values

Question 1


Assume s is a string of numbers.
Write a program that checks the string s for the values '2', '3', '5' and '7'.  When one of the values is found in the string, record its position within the string and continue to check for more occurrences.  Finally, output the results found.
For example, if s = '568714523645873', your program should print:

2 - 7
3 - 8 14
5 - 0 6 11
7 - 3 13

Give Five (5) different examples with its output.

Hint
Management Codes='56567788885657755'#s='222200005'#array to hold string for occurence indices of each numbercountStrs=['2 -','3 -','5 -','7 -']#current loop indexcurrIndex=-1#get each number, convert it to an int, update current index then update corresponding count string if 2, 3, 5 or 7for numChar in s:...

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.