알고리즘/코드워

[python]Is the string uppercase?

(ㅇㅅㅎ) 2020. 4. 12. 19:51
728x90
반응형

https://www.codewars.com/kata/56cd44e1aa4ac7879200010b/train/python

 

Codewars: Train your coding skills

Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.

www.codewars.com

더보기

내 코드

isupper() 함수로 문제를 풀 수 있다.

# My Code
def is_uppercase(inp):
    for i in inp:
        if i.islower():
            return False
    return True
 
def is_uppercase1_(inp):
    return str.isupper(inp)
 
if __name__=='__main__':
    answer = is_uppercase("c")
    print(answer)
    answer = is_uppercase("C")
    print(answer)
    answer = is_uppercase("hello I Am DONALD")
    print(answer)
    answer = is_uppercase("HELLO I AM DONALD")
    print(answer)
반응형

'알고리즘 > 코드워' 카테고리의 다른 글

[python]Sum of positive  (0) 2020.04.15
[python]Permutations  (0) 2020.04.13
[python]Make a spiral  (0) 2020.04.11
[python]altERnaTIng cAsE <=> ALTerNAtiNG CaSe  (0) 2020.04.08
[python]Is my friend cheating?  (0) 2020.04.06