Python 输入字符串找(String)下标 没有返回-1
str = "abcdefg123456"
a = input("请输入一个字母或数字:")
num = 0
result = -1
while num < len(str):
if str[num] == a:
result = num
num += 1
print(result)
Q群:592857363
str = "abcdefg123456"
a = input("请输入一个字母或数字:")
num = 0
result = -1
while num < len(str):
if str[num] == a:
result = num
num += 1
print(result)
Q群:592857363