可以通过其他方法检测空间并打印出附加空格的数字

时间:2018-06-21 14:52:06

标签: python-3.x

我只是python的初学者。 我想知道有什么办法可以解决我对代码所做的相同事情。 只是为了使我的代码更整洁,我想知道任何快捷方式或带有dict的东西,通过它们我可以检测到附加空格的数字。

def space(text):
num = 0
print ('I will find the number where space is appended')
for i in text:
    if i.isspace() == True:
        print ('Space is on ' + str(num1))
        break
    num = num + 1
    print ('The ' + str(num) + ' character is ' + str(i) + '.')
    num1 = num + 1

para ='Aman dhaker'

space(para)

对不起,英语不好。 干杯

0 个答案:

没有答案