|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- >>> i = 0
- >>> string = "ILoveFishC.com"
- >>> Length = len(string)
- >>> while i < length:
- print(i)
- i += 1
-
- Traceback (most recent call last):
- File "<pyshell#21>", line 1, in <module>
- while i < length:
- NameError: name 'length' is not defined
- >>>
复制代码
本帖最后由 Twilight6 于 2020-8-1 13:52 编辑
第一个的 Length 的 L 是大写的,第二个 length 的 l 是小写的
改成这样即可:
- i = 0
- string = "ILoveFishC.com"
- Length = len(string)
- while i < Length:
- print(i)
- i += 1
复制代码
或者两个 length 都改成小写的:
- i = 0
- string = "ILoveFishC.com"
- length = len(string)
- while i < length:
- print(i)
- i += 1
复制代码
|
|