Re: [Tutor] Help with writing a program
On 03/12/12 14:59, rajesh mullings wrote: Hello, I am trying to write a program which takes two lines of input, one called "a", and one called "b", which are both strings, then outputs the number of times a is a substring of b. If you could give me an algorithm/pseudo code of what I should do to create this program, I would greatly appreciate that. Thank you for using your time to consider my request. Are you talking about something like this? a = "ing" b = """\ Our ingenious plan worked, and the Laughing Prince, last seen capering madly while his Motley Monks sat gibbering, was soon vanquished, though not without some achingly painful experiences. """ count(b, a) => should return 5 If that is what you want, try reading the Fine Manual about string methods, and you can count on finding something to help solve this problem. https://duckduckgo.com/?q=python%20string%20methods -- Steven ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with writing a program
There is an equivalent page in the documentation for Python 3 as well, regarding strings. This sounds a lot like a homework problem so you are unlikely to get a lot of help. You certainly won't get exact code. What have you tried so far? Where are you getting stuck? We're not here to write code for you, this list is meant to help you learn something yourself. If you just want someone to write code for you there are plenty of sites that will do that. But if you want to figure it out I'd be happy to give you some hints if I can see that you're making some effort. One effort you could make would be to find the relevant Python 3 document discussing strings and check if it has some references to finding substrings. Let me know what you try and I'll help you if you get stuck. Thanks, -Luke On Sun, Dec 2, 2012 at 11:31 PM, fantasticrm wrote: > The Python version, is Python 3. > > > On Sun, Dec 2, 2012 at 10:59 PM, rajesh mullings wrote: > >> Hello, I am trying to write a program which takes two lines of input, one >> called "a", and one called "b", which are both strings, then outputs the >> number of times a is a substring of b. If you could give me an >> algorithm/pseudo code of what I should do to create this program, I would >> greatly appreciate that. Thank you for using your time to consider my >> request. > > > > ___ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > > ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with writing a program
The Python version, is Python 3. On Sun, Dec 2, 2012 at 10:59 PM, rajesh mullings wrote: > Hello, I am trying to write a program which takes two lines of input, one > called "a", and one called "b", which are both strings, then outputs the > number of times a is a substring of b. If you could give me an > algorithm/pseudo code of what I should do to create this program, I would > greatly appreciate that. Thank you for using your time to consider my > request. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with writing a program
On 03/12/2012 03:59, rajesh mullings wrote: Hello, I am trying to write a program which takes two lines of input, one called "a", and one called "b", which are both strings, then outputs the number of times a is a substring of b. If you could give me an algorithm/pseudo code of what I should do to create this program, I would greatly appreciate that. Thank you for using your time to consider my request. Start here http://docs.python.org/2/library/string.html -- Cheers. Mark Lawrence. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help with writing a program
Hello, I am trying to write a program which takes two lines of input, one called "a", and one called "b", which are both strings, then outputs the number of times a is a substring of b. If you could give me an algorithm/pseudo code of what I should do to create this program, I would greatly appreciate that. Thank you for using your time to consider my request. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor