私はpythonで単語を感知するプログラムに取り組んでいます。ユーザー入力 = 私のメール ID は harry@hogwarts.com 出力 = 私のメール ID は xxxxx@hogwarts.com
これは私がこれまでに持っているものです
def main():
message = []
userInput = str(input("Enter the sentence: "))
splitInput = str(list(userInput))
print(splitInput)
for item in splitInput:
indeces = splitInput.index('@')
while((indeces-1).isalpha()):
item = 'x'
message.append(item)
print(' '.join(message))
これは私が得るエラーです
File "C:\Users\Manmohit\Desktop\purifier.py", line 8, in main
while((indeces-1).isalpha()):
AttributeError: 'int' object has no attribute 'isalpha'
私はさまざまな方法をオンラインで探してみました。私はアルファメソッドに似たものが欲しいです。チェックするために独自のアルファメソッドを作成する必要がありますか、それとも組み込みのものを使用できますか??? 助けていただければ幸いです。ありがとうございました
更新:
ループwhile((indeces-1).isalpha()):
を変更するwhile((str(indeces-1)).isalpha()):
と、エラーは発生しませんが、出力も得られません。