-3

This is the problem I am facing. Can anyone help

name=input("What is your name?")
name= input.lower()

when it runs this is what comes up

What is your name?Bob

Traceback (most recent call last):
  File "E:\eval task 1 GCSE.py", line 6, in <module>
    name= input.lower()
AttributeError: 'builtin_function_or_method' object has no attribute 'lower'

can anyone fix this please. I need to make sure that I can only enter letters from the alphabet for my name input. Can anyone show me how to do this. Very appreciated

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
GamingKing720
  • 11
  • 1
  • 4
  • 5
    You get the user input with the `input` function, then store it in a variable `name`. You then try to call the `lower` method of the `input` function which doesn't exist. Change `input.lower()` to `name.lower()`. – Colonel Thirty Two Oct 13 '15 at 21:56
  • Your intention isn't completely clear. Do you need to reject the input outright if it contains numeric characters? Or do you want to keep the input but merely filter the non-alphabetic characters? – foundling Oct 13 '15 at 22:15
  • Basically I want make a variable called name which only accepts letter from the alphabet. If they input an integer instead then I want it to stop and print this I not a valid name – GamingKing720 Oct 13 '15 at 22:18
  • Just posted an answer for you, hope that helps. – foundling Oct 13 '15 at 23:09

2 Answers2

4

call lower on name instead:

name = name.lower()
Ryan
  • 2,058
  • 1
  • 15
  • 29
0

Try this:

username=input("What is your name?").lower()
for char in username:
    if not char.isalpha():
        print "invalid username"
        break
foundling
  • 1,695
  • 1
  • 16
  • 22