Python 范围内x的错误:TypeError:';类型';对象是不可编辑的

Python 范围内x的错误:TypeError:';类型';对象是不可编辑的,python,python-3.x,Python,Python 3.x,我试图运行一个程序,用户在其中键入两个单词,我必须找到该单词的最后一个字母。在那之后,我必须找出那个字母是否在第二个单词里。我是这样开始的: x=input('Type a word') y=input('Type another word') for x in range: print (x[-1]) 发生此错误是因为您无法迭代非生成器函数实例 要实现您的目标,一种更好、更具python风格的方法是: x=input('Type a word') y=input('Type anot

我试图运行一个程序,用户在其中键入两个单词,我必须找到该单词的最后一个字母。在那之后,我必须找出那个字母是否在第二个单词里。我是这样开始的:

x=input('Type a word')
y=input('Type another word')
for x in range:
    print (x[-1])

发生此错误是因为您无法迭代非生成器函数实例

要实现您的目标,一种更好、更具python风格的方法是:

x=input('Type a word')
y=input('Type another word')

if x[-1] in y:
    print('its there alright :)')

发生此错误是因为您无法迭代非生成器函数实例

要实现您的目标,一种更好、更具python风格的方法是:

x=input('Type a word')
y=input('Type another word')

if x[-1] in y:
    print('its there alright :)')

发生此错误是因为您无法迭代非生成器函数实例

要实现您的目标,一种更好、更具python风格的方法是:

x=input('Type a word')
y=input('Type another word')

if x[-1] in y:
    print('its there alright :)')

发生此错误是因为您无法迭代非生成器函数实例

要实现您的目标,一种更好、更具python风格的方法是:

x=input('Type a word')
y=input('Type another word')

if x[-1] in y:
    print('its there alright :)')

您正在尝试迭代对范围函数的引用!您正在尝试迭代对范围函数的引用!您正在尝试迭代对范围函数的引用!您正在尝试迭代对范围函数的引用!