1. 程式人生 > >關於索引和數字判斷的小例子

關於索引和數字判斷的小例子

## 計算使用者輸入 input內容中,索引為奇數並且and 對應的元素為數字isdigit的個數(沒有則為0)
count = 0
content = input("請輸入內容>>>>")
for i in range(len(content)):
if i % 2 == 1 and content[i].isdigit():
count = count + 1
print(count)