완숙의 블로그

[Python] 6 - Conditional Statement 본문

Programing Language/Python

[Python] 6 - Conditional Statement

완숙 2019. 4. 10. 23:27

C++과 약간의 차이를 기억해야 하는데,

가장 핵심적인 것은

OR, AND 를 그대로 갖다 쓴다는 것이다.

 

C++에서는 각각 && , || 로 사용했는데,

이것을 AND, OR 로 사용하면 된다.

 

문자열에서 특정 문자 갯수 세는 프로그램 개발하기

 

def calcCharacterFromString(sentence, inputChar):
    numChs = sentence.count(inputChar)
    return numChs
    
sentence = 'Mary had a little lamb'
inputChar = input("Enter the Char : ")

calcCharacterFromString(sentence, inputChar)

 

 

'Programing Language > Python' 카테고리의 다른 글

[Python] 8 - Method and Class  (0) 2019.04.10
[Python] 7 - Module  (0) 2019.04.10
[Python] 5 - String  (0) 2019.04.10
[Python] 4 - Function Design Recipe (FDR)  (0) 2019.03.20
[Python] 3 - Variables  (0) 2019.03.20
Comments