파이썬 내가 공부한 흔적
QUIZ3/replace() , index() , [:] , str() , len() , count() , {} .format()/ python / 파이썬
무한머니
2022. 3. 19. 20:00
# Quiz) 사이트별로 비밀번호를 만들어 주는 프로그램을 작성하시오
# 예) http : // naver.com
# 규칙1 : http : // 부분은 제외 => naver.com
# 규칙2 : 처음 만나는 점 (.) 이후 부분은 제외 = > naver
# 규칙3 : 남은 글자 중 처음 세자리 + 글자 갯수 + 글자 내 'e' 갯수 + "!" 로 구성
# 예 ) 생성된 비밀번호 : nav51!
#-----------------내가 한 흔적--------------------------------------
# #print("규칙 1답 \bh\bt\bt\bp \b: \b/\b/\b naver.com") / 잘 나오긴함
# # san = "http : // "
# # san2 = "naver"
# # san3 = ".com"
# # print("{san}{san2}{san3}")
# site = "http : // naver.com "
# print(site. count('n'))
# # python = "Python is Amazing"
# # print(python. count("n"))
#-----------------내가 한 흔적---------------------------------------
# 규칙 1
#규칙1 : http : // 부분은 제외 => naver.com
my_str = url.replace("http://","")
print(my_str) # naver.com
# 규칙 2
# 규칙2 : 처음 만나는 점 (.) 이후 부분은 제외 = > naver
my_str = my_str[:(my_str.index("."))] # my_str = naver.com 라는 문장에서 처음부터(:) index(".") 점이있는 곳 전까지
print(my_str) # naver
# 규칙 3
# 규칙3 : 남은 글자 중 처음 세자리 + 글자 갯수 + 글자 내 'e' 갯수 + "!" 로 구성
password = my_str[:3] + str(len(my_str)) +str(my_str.count("e")) + "!"
print(password)
print("{0}의 비밀번호는 {1}입니다" .format(url , password))
naver.com
naver
nav51!
http://naver.com 의 비밀번호는 nav51!입니다
PS C:\Users\ASUS\Desktop\walkspace>
