2016-08-29 4 views

答えて

6

何を求めていることはstr.isalpha()機能である:

isalpha(...) 
    S.isalpha() -> bool 

    Return True if all characters in S are alphabetic 
    and there is at least one character in S, False otherwise. 

たとえば、あなたはこのようにそれを使用することができます:

def ask_name(): 
    while True: 
     name = raw_input("What is your name?") 
     if name.isalpha(): 
      return name 
     else: 
      print("Please use only letters, try again") 
関連する問題