0
入力を受け取り、特殊文字を削除し、すべての大文字を小文字にし、オフセットが5のASCIIコードに変換し、オフセット値を文字に戻して単語にする必要があります。 「int型のオブジェクトは、あなたがintとしてループ上result
を毎回宣言しているので、あなたがTypeError: 'int' object is not iterable at the end
を取得している最後にASCIIコードをテキストに変換するには?
string=(str(raw_input("The code is:")))
#change it to lower case
string_lowercase=string.lower()
print "lower case string is:", string_lowercase
#strip special characters
specialcharacters="1234567890~`[email protected]#$%^&*()_-+={[}]|\:;'<,>.?/"
for char in specialcharacters:
string_lowercase=string_lowercase.replace(char,"")
print "With the specials stripped out the string is:", string_lowercase
#input offset
offset=(int(raw_input("enter offset:")))
#converstion of text to ASCII code
for i in string_lowercase:
code=ord(i)
result=code-offset
#converstion from ASCII code to text
for number in result:
message=repre(unichr(number))
print message
'result'は' int'です。あなたはそれを反復しようとしています。代わりにあなたが望むのは 'result.append(code-offset)'だと思います。つまり、実際に 'result'引数を' list'として初期化する必要があるので、 'result = []'はループの前に置かなければなりません。 – idjaw