본문 바로가기

전공(Major)

[python]동일한 단어 사이값 추출을 위한 자료1

 index = 0
  while index < len(fruit):
    letter = fruit[index]
    print letter
    index = index + 1


def find(str, ch):
    index = 0
    while index < len(str):
      if str[index] == ch:
        return index
      index = index + 1
    return -1

 

 fruit = "banana"
  count = 0
  index = 0
  for char in fruit:
    if char == 'a':
      count = count + 1
  print count