• 회원가입
  • 로그인
  • 구글아이디로 로그인

[keyword] Python - in 키워드 - 값 유무(= 존재 여부) 체크. ※ for 반복문에도 사용.

11989  
목차
  1. in 예제 - 지정값 존재 여부 체크
  2. in 정의
  3. in 예제 - for 반복문 경우
  4. not in 예제 - 비존재 여부 체크

 

in 예제 - 지정값 존재 여부 체크


code = ["HTML", "CSS", "JS"]

if "CSS" in code:

  print("존재 O")

 

결과값: 존재 O

 

in 정의

※ 2가지 용도 있음.

 

1. 지정 값이 '데이터 꾸러미'에 있는지 체크.

2. for 반복문에서 '데이터 꾸러미' 반복 실행.

 


PS.

not in 키워드 : 값이 존재 안 함 체크. 

 

 

in 예제 - for 반복문 경우

 

code = ["HTML", "CSS", "JS"]

for x in code:

    print(x)

 

결과값:

HTML

CSS

JS

 

not in 예제 - 비존재 여부 체크


code = ["HTML", "CSS", "JS"]

if "SQL" not in code:

  print("존재 X")

 

결과값: 존재 X



분류 제목
module Python - statistics.mode() 메서드 ★ - 최빈값 반환. (= mode메서드 = 모드)
module Python - statistics.pstdev() 메서드 -
module Python - statistics.stdev() 메서드 -
module Python - statistics.pvariance() 메서드 -
module Python - statistics.variance() 메서드 -
module Python - math 모듈 메서드・상수 종류 (※ 수학 모듈)
module Python - math.acos() 메서드 -
module Python - math.acosh() 메서드 -
module Python - math.asin() 메서드 -
module Python - math.asinh() 메서드 -
module Python - math.atan() 메서드 -
module Python - math.atan2() 메서드 -
module Python - math.atanh() 메서드 -
module Python - math.ceil() 메서드 ★ - 천장 반올림 (= 상위 정수로 반올림. = ceil메서드…
module Python - math.comb() 메서드 -
module Python - math.copysign() 메서드 -
module Python - math.cos() 메서드 -
module Python - math.cosh() 메서드 -
module Python - math.degrees() 메서드 -
module Python - math.dist() 메서드 -
19/24
목록
찾아주셔서 감사합니다. Since 2012