<div dir="ltr">Hey, I'm new to programming <div>running Python 2.7.8 Windows 8.1</div><div>I was reading 'How to Think Like a Computer Scientist- Learning with Python'</div><div>chapter 7 sub-chapter 7.7</div><div><br></div><div>I have the following code: </div><div><div>names = "John, Cindy, Peter"</div><div>def find(str, ch, s):</div><div>    index = 0</div><div>    while index < len(str):</div><div>        if s==1:</div><div>            for char in names[:4]:</div><div>                if str[index] == ch:</div><div>                    return index + 1</div><div>                index = index + 1</div><div>        if s==2:</div><div>            for char in names[6:11]:</div><div>                if str[index] == ch:</div><div>                    return index + 1</div><div>                index = index + 1</div><div>        if s==3:</div><div>            for char in names[13:]:</div><div>                if str[index] == ch:</div><div>                    return index + 1</div><div>                index = index + 1</div><div>    return -1</div><div>print find(names,"n", 2)</div></div><div><br></div><div><br></div><div><br></div><div>and my problem is:</div><div>I intend for the parameter s to tell the interpreter which name to look at </div><div>so that i get the index return value related to that name.</div><div>for example:</div><div>John and Cindy both have a letter 'n' but when I call the function</div><div>with an s value of 2 I want it to return the index value of the letter n in Cindy and not in John.</div><div><br></div><div>Can Someone Please tell me why my code isn't working like I intend it to?</div><div>Thank you</div><div><br></div></div>