J o e
JoE's StOrY
J o e
  • 분류 전체보기 (206)
    • workSpace (184)
      • 도메인 지식 (2)
      • ALGORITHM (39)
      • ANDROID (3)
      • JS (0)
      • JAVA (21)
      • MYSQL (6)
      • NETWORK (3)
      • PYTHON (91)
      • LINUX (9)
      • PROJECT (4)
    • Others (20)
      • Opic (1)
      • myLife (17)
      • popSong (1)
      • 정보처리기사 (1)
    • 훈빠의 특강 (0)
      • opencv (0)
      • python (0)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

  • The code with long statements is⋯
  • 매일 매일이 행복하고 밝은 날이 될거에요

인기 글

태그

  • Fully Connected Network
  • 태블릿 연동
  • DTO
  • sort_value
  • dao
  • MySQL
  • ㅖ43
  • read_html
  • linearclassification
  • 단어의 개수
  • sort_index
  • full loss
  • Python
  • 넘파이함수
  • java
  • 넘파이 문제
  • How to create a GUI in Java with JFrame?
  • 이미지 연산
  • 파이썬
  • numpy

최근 댓글

최근 글

티스토리

J o e

WHY?

[Python] 주소록 프로그램
workSpace/PYTHON

[Python] 주소록 프로그램

2020. 12. 26. 20:23
prompt = """
1. 추가
2. 검색(이름)
3. 수정
4. 삭제
5. 전체 출력
6. 전체 삭제
7. 종료
Enter number :
"""
userList = []


def add():
    global userList
    userInfo = nameCheck()
    userList.append(userInfo)


def nameCheck():
    while True:
        name = input("이름 :")
        phoneNum = int(input("전화번호 :"))
        address = input("주소 :")
        userInfo = [name, phoneNum, address]

        search(name)
        if name == search(name):
            print('중복된 이름')
        else:
            break
    return userInfo


def search(name):
    for i in range(0, len(userList)):
        if name in userList[i][0]:
            # 변수 in list[] 로 리스트 안에 값이 있는지 확인 할 수있다.
            return name


def searchName():
    searchName = (input("이름:"))
    for i in range(0, len(userList)):
        if userList[i][0] == searchName:
            print("정보 있음 :", userList[i][0], userList[i][1], userList[i][2])
            break
        else:
            print("정보 없음")


def edit():
    searchName = input("이름:")
    for i in range(0, len(userList)):
        if userList[i][0] == searchName:
            print("정보 있음 :", userList[i][0], userList[i][1], userList[i][2])
            quest = input("어떤 정보를 수정하시겠습니까? [이름, 번호, 주소] :")
            if quest == "이름":
                while True:
                    etName = input("수정할 이름 :")
                    if search(etName) == etName:
                        print("중복된 이름 입니다.")
                    else:
                        userList[i][0] = etName
                        break

            elif quest == "번호":
                userList[i][1] = input("수정할 번호 :")

            elif quest == "주소":
                userList[i][2] = input("수정할 주소 :")

            print()
            print("수정되었습니다.")
            break

        elif userList[i][0] != searchName:
            print("정보 없음")


def remove():
    searchName = input("이름:")
    for i in range(0, len(userList)):
        if userList[i][0] == searchName:
            print("정보 있음 :", userList[i][0], userList[i][1], userList[i][2])
            quest = input("삭제 하시겠습니까? [예, 아니오] :")
            if quest == "예":
                userList.remove(userList[i])
                print("삭제 되었습니다.")
                break
            elif quest == "아니오":
                break
        else:
            print("정보 없음")


def removeAll():
    quest = input("전체삭제 하시겠습니까? [예, 아니오] :")
    if quest == "예":
        userList.clear()


number = 0
while number != 7:
    print(prompt)
    number = int(input())

    if number == 1:
        print("추가")
        add()

    if number == 2:
        print("검색")
        searchName()

    if number == 3:
        print("수정")
        edit()

    if number == 4:
        print("삭제")
        remove()

    if number == 5:
        print("전체 출력")
        userList.sort()
        print(userList)

    if number == 6:
        print("전체 삭제")
        removeAll()

    if number == 7:
        print("종료")

    if number >= 8:
        print("숫자를 다시 입력해주세요.")

'workSpace > PYTHON' 카테고리의 다른 글

[Python] 제품입고정리 프로그램 (MVC pattern)  (0) 2020.12.26
[Python] 파일 생성 수정 삭제  (0) 2020.12.26
[Python] 제품입출력 프로그램 (MVC pattern)  (0) 2020.12.26
[Python] 성적입출력 프로그램 (MVC pattern)  (0) 2020.12.26
[Python] bubble, insert, select sorting + 이진탐색  (0) 2020.12.26
    'workSpace/PYTHON' 카테고리의 다른 글
    • [Python] 제품입고정리 프로그램 (MVC pattern)
    • [Python] 파일 생성 수정 삭제
    • [Python] 제품입출력 프로그램 (MVC pattern)
    • [Python] 성적입출력 프로그램 (MVC pattern)
    J o e
    J o e
    나의 과거를 기록합니다.

    티스토리툴바