모두가함께하는프로그래밍3 python Data structures 8.4 list 문제 8.4 Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort and print the resulting words in alphabetical order. You can download the sample.. 2022. 1. 15. 파이썬의 다양한 string 함수 예시 1. string() 함수 word = 'banana' fruit = word.replace('ban','apple') 이라 함은 banana의 ban을 apple로 바꿔주는 역할 즉 출력 값은 appleana 가 된다 여러 반복되는 글자들도 banana 의 a를 -> o를 바꾸고 출력한 값임 즉 bonono가 됨 2.strip() ,lstrip(),rstrip()함수 출력문만 봐도 바로 이해가 가듯 공백을 제거해주는 함수 strip은 왼쪽오른쪽 전부 제거 lstrip은 왼쪽 공백제거 rstrip은 오른쪽 공백제거 2022. 1. 14. 모두를 위한 프로그래밍 7주차 for 문을 이용하는 강의 파이썬은 복수형을 이해하지 못하기 때문에 아래 예시에서는 리스트 형으로 이해하여 오른쪽 처럼 출력하게 하게 된다 과제 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. En.. 2022. 1. 13. 이전 1 다음