I'm a bit of a python amateur and I'm creating an extremely basic program. I need it to format a user's input into title format like so:
Input: hello
Output: Hello
This is what I have so far:
firstNameInput = input("Hello! What is your first name? \\n")
firstName = firstNameInput.title
When I come to print firstName I get no error, however instead of printing firstName it prints:
<built-in method title of str object at 0x0000000003EA60D8>
Thanks for any help in advance! :)
firstNameInput.title()
you are missing parens
In [1]: s = "hello world"
In [2]:print (s.title)
Out[2]:<built-in method title of str object at 0x7fbea30830b0>
In [3]: s.title()
Out[3]: 'Hello World'
The first is a reference to the method, the second is actually calling it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.