Help with code?

This is the place for queries that don't fit in any of the other categories.

Help with code?

Postby newb1 » Sat Mar 23, 2013 9:21 pm

Can someone please let me know why the .lower method is not doing what I expect? I am expecting it to compare the lowercase of friends with the string "y". However, when i print friends.lower it returns:

Code: Select all
<built-in method lower of str object at 0x00000000028873E8>


Code: Select all
fList = input("Please enter your name: ")
friends = "Y"
while friends.lower == "y":
    friends = input("Do you have friends with you? (y or n)")
    fList.append(input("Great! Please enter the first name: "))
print ("Great! Hello, Brave Traveler: "+str(fList))
newb1
 
Posts: 5
Joined: Tue Mar 05, 2013 3:17 am

Re: Help with code?

Postby setrofim » Sat Mar 23, 2013 9:23 pm

It's
Code: Select all
friends.lower()

not
Code: Select all
friends.lower

Note the parens.
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: Help with code?

Postby newb1 » Sat Mar 23, 2013 10:18 pm

Thank you!!
newb1
 
Posts: 5
Joined: Tue Mar 05, 2013 3:17 am


Return to General Coding Help

Who is online

Users browsing this forum: Baidu [Spider] and 3 guests