# [Tutor] Python HW question

Alan Gauld alan.gauld at yahoo.co.uk
Sat Sep 16 03:55:50 EDT 2017

```On 16/09/17 01:32, miknau1 at gmail.com wrote:

> I really need some Python help. I’m a beginner and have some hw for class:

OK, Usual caveat: we don;t do your homework, just give hints.

> Write a program that calculates longest substring of increasing letters in st, say st=‘Supercalifragilisticexpialidocious’. Do it in a few steps:

I'm assuming that means a string where each letter is higher
than the previous one, such as 'best'?

> 1.Find longest increasing substring starting from 0th position,
> use comparison <= to check if one letter greater than other

You don't tell us about how much Python or programming
experience you have so I'll assume its near zero and
apologize if I'm pitching too low.

Do you know how to write some code to check each letter
in a string, one by one? If so could you write a short
program to test whether a string is increasing? ie start
at the beginning and check whether each letter is greater
than the previous one.

If you can do that then the rest of the homework
becomes much easier.

Do you know how to define your own function? If so that
will also make things slightly simpler.

> 2. Use function len of object str(ing) to find length of string
> 3.Write one line of code that choses longest string from 2

If you can do 2 then 3 is trivial.

For example if we have two strings:

s1 = 'Python'
s2 = 'Perl'

Can you write code to display the lengths of s1 and s2?
Can you then write a single line of code that chooses
which string is longesst?

> 4. Loop through all possible starting position start> of the str, and find longest increasing substring of st.

This is combining step 1 with steps 2 and 3.

> I have no idea where to start this problem.

string is an increasing string. If you know how put
it in a function, but that's a nice to have...

If you get stuck come back here and show us the code
fix it.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos

```