본문 바로가기
Python/왕초보를 위한 파이썬

Python 실습_After Index

by 가므자 2012. 4. 10.
After Index
You can return a portion of a string from some index onwards by using the bracket operator and and the expression index:. For example: if color = 'blue' then color[1:] = 'lue' since the result is all of the characters in color from the index onwards. Create a function called after_index() that accepts a string and a number n as parameters and returns a string consisting of the characters from the index to the end of the string.

Results
Call Expected Received Correct
after_index('red',1) ed ed true
after_index('blue',2) ue ue true
after_index('blue',4) true
 

'Python > 왕초보를 위한 파이썬' 카테고리의 다른 글

Python 문자열  (0) 2012.04.10
Python 실습_Replace at Index  (0) 2012.04.10
Python 실습_Character Replacement  (0) 2012.04.10
Python 실습_Alphabet count  (0) 2012.04.10
Python 실습_Capitalize Even Items  (0) 2012.04.10

댓글