Question

I have a simple python script that has an objective of printing an extra line when a particular name is typed in. This works in 3.3.4, however when I tried to run it in 2.7.6 the extra line wasn't printed when the name was entered in. I am guessing there is something I over looked in the changelog between both python versions. Help is greatly appreciated.

while True:
    name =raw_input('Piggy: What is your name?\n').strip()
    if len(name.split()) == 1:
        name = name.title()
        break
    else:
        print("Ahhhj Make it shorter or actually enter a name. If you have a name like 'Mary Joe', please separate it by using a '-'")
if name ==('dawson'):
    print('Hey Developer.')
Was it helpful?

Solution

You call name.title() and replace name, and then you compare it with a lowercase string. It will never match.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top