-3
Я новичок в python, и у меня проблемы со строками. Я получаю «AttributeError: объект« str »не имеет атрибута», но я не понимаю, почему. Я предоставил часть своего кода, поэтому любой совет будет полезен!AttributeError: объект 'str' не имеет атрибута isalpha()
#Have user enter their string.
string = input("Enter a string: ")
#Find if string only contains letters and spaces
if string.isalpha():
print("Only alphabetic letters and spaces: yes")
else:
print("Only alphabetic letters and spaces: no")
#Find if string is only numeric.
if string.isdigits():
print("Only numeric digits: yes")
else:
print("Only numeric digits: no")
Ошибка атрибута происходит, когда метод не определен. –