Higher Lower Game

data = [
    {
        'name': 'Instagram',
        'follower_count': 346,
        'description': 'Social media platform',
        'country': 'United States'
    },
    {
        'name': 'Cristiano Ronaldo',
        'follower_count': 215,
        'description': 'Footballer',
        'country': 'Portugal'
    },
    {
        'name': 'Ariana Grande',
        'follower_count': 183,
        'description': 'Musician and actress',
        'country': 'United States'
    },
    {
        'name': 'Dwayne Johnson',
        'follower_count': 181,
        'description': 'Actor and professional wrestler',
        'country': 'United States'
    },
    {
        'name': 'Selena Gomez',
        'follower_count': 174,
        'description': 'Musician and actress',
        'country': 'United States'
    },
    {
        'name': 'Kylie Jenner',
        'follower_count': 172,
        'description': 'Reality TV personality and businesswoman and Self-Made Billionaire',
        'country': 'United States'
    },
    {
        'name': 'Kim Kardashian',
        'follower_count': 167,
        'description': 'Reality TV personality and businesswoman',
        'country': 'United States'
    },
    {
        'name': 'Lionel Messi',
        'follower_count': 149,
        'description': 'Footballer',
        'country': 'Argentina'
    },
    {
        'name': 'Beyoncé',
        'follower_count': 145,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'Neymar',
        'follower_count': 138,
        'description': 'Footballer',
        'country': 'Brasil'
    },
    {
        'name': 'National Geographic',
        'follower_count': 135,
        'description': 'Magazine',
        'country': 'United States'
    },
    {
        'name': 'Justin Bieber',
        'follower_count': 133,
        'description': 'Musician',
        'country': 'Canada'
    },
    {
        'name': 'Taylor Swift',
        'follower_count': 131,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'Kendall Jenner',
        'follower_count': 127,
        'description': 'Reality TV personality and Model',
        'country': 'United States'
    },
    {
        'name': 'Jennifer Lopez',
        'follower_count': 119,
        'description': 'Musician and actress',
        'country': 'United States'
    },
    {
        'name': 'Nicki Minaj',
        'follower_count': 113,
        'description': 'Musician',
        'country': 'Trinidad and Tobago'
    },
    {
        'name': 'Nike',
        'follower_count': 109,
        'description': 'Sportswear multinational',
        'country': 'United States'
    },
    {
        'name': 'Khloé Kardashian',
        'follower_count': 108,
        'description': 'Reality TV personality and businesswoman',
        'country': 'United States'
    },
    {
        'name': 'Miley Cyrus',
        'follower_count': 107,
        'description': 'Musician and actress',
        'country': 'United States'
    },
    {
        'name': 'Katy Perry',
        'follower_count': 94,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'Kourtney Kardashian',
        'follower_count': 90,
        'description': 'Reality TV personality',
        'country': 'United States'
    },
    {
        'name': 'Kevin Hart',
        'follower_count': 89,
        'description': 'Comedian and actor',
        'country': 'United States'
    },
    {
        'name': 'Ellen DeGeneres',
        'follower_count': 87,
        'description': 'Comedian',
        'country': 'United States'
    },
    {
        'name': 'Real Madrid CF',
        'follower_count': 86,
        'description': 'Football club',
        'country': 'Spain'
    },
    {
        'name': 'FC Barcelona',
        'follower_count': 85,
        'description': 'Football club',
        'country': 'Spain'
    },
    {
        'name': 'Rihanna',
        'follower_count': 81,
        'description': 'Musician and businesswoman',
        'country': 'Barbados'
    },
    {
        'name': 'Demi Lovato',
        'follower_count': 80,
        'description': 'Musician and actress',
        'country': 'United States'
    },
    {
        'name': "Victoria's Secret",
        'follower_count': 69,
        'description': 'Lingerie brand',
        'country': 'United States'
    },
    {
        'name': 'Zendaya',
        'follower_count': 68,
        'description': 'Actress and musician',
        'country': 'United States'
    },
    {
        'name': 'Shakira',
        'follower_count': 66,
        'description': 'Musician',
        'country': 'Colombia'
    },
    {
        'name': 'Drake',
        'follower_count': 65,
        'description': 'Musician',
        'country': 'Canada'
    },
    {
        'name': 'Chris Brown',
        'follower_count': 64,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'LeBron James',
        'follower_count': 63,
        'description': 'Basketball player',
        'country': 'United States'
    },
    {
        'name': 'Vin Diesel',
        'follower_count': 62,
        'description': 'Actor',
        'country': 'United States'
    },
    {
        'name': 'Cardi B',
        'follower_count': 67,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'David Beckham',
        'follower_count': 82,
        'description': 'Footballer',
        'country': 'United Kingdom'
    },
    {
        'name': 'Billie Eilish',
        'follower_count': 61,
        'description': 'Musician',
        'country': 'United States'
    },
    {
        'name': 'Justin Timberlake',
        'follower_count': 59,
        'description': 'Musician and actor',
        'country': 'United States'
    },
    {
        'name': 'UEFA Champions League',
        'follower_count': 58,
        'description': 'Club football competition',
        'country': 'Europe'
    },
    {
        'name': 'NASA',
        'follower_count': 56,
        'description': 'Space agency',
        'country': 'United States'
    },
    {
        'name': 'Emma Watson',
        'follower_count': 56,
        'description': 'Actress',
        'country': 'United Kingdom'
    },
    {
        'name': 'Shawn Mendes',
        'follower_count': 57,
        'description': 'Musician',
        'country': 'Canada'
    },
    {
        'name': 'Virat Kohli',
        'follower_count': 55,
        'description': 'Cricketer',
        'country': 'India'
    },
    {
        'name': 'Gigi Hadid',
        'follower_count': 54,
        'description': 'Model',
        'country': 'United States'
    },
    {
        'name': 'Priyanka Chopra Jonas',
        'follower_count': 53,
        'description': 'Actress and musician',
        'country': 'India'
    },
    {
        'name': '9GAG',
        'follower_count': 52,
        'description': 'Social media platform',
        'country': 'China'
    },
    {
        'name': 'Ronaldinho',
        'follower_count': 51,
        'description': 'Footballer',
        'country': 'Brasil'
    },
    {
        'name': 'Maluma',
        'follower_count': 50,
        'description': 'Musician',
        'country': 'Colombia'
    },
    {
        'name': 'Camila Cabello',
        'follower_count': 49,
        'description': 'Musician',
        'country': 'Cuba'
    },
    {
        'name': 'NBA',
        'follower_count': 47,
        'description': 'Club Basketball Competition',
        'country': 'United States'
    }
]

import random

logo = '''
 _   _ _       _                 _
| | | (_)     | |               | |
| |_| |_  __ _| |__   ___ _ __  | |     _____      _____ _ __
|  _  | |/ _` | '_ \ / _ \ '__| | |    / _ \ \ /\ / / _ \ '__|
| | | | | (_| | | | |  __/ |    | |___| (_) \ V  V /  __/ |
\_| |_/_|\__, |_| |_|\___|_|    \_____/\___/ \_/\_/ \___|_|
          __/ |
         |___/
 _____
|  __ \
| |  \/ __ _ _ __ ___   ___
| | __ / _` | '_ ` _ \ / _ \
| |_\ \ (_| | | | | | |  __/
 \____/\__,_|_| |_| |_|\___|


'''


vs = '''
__   _____
\ \ / / __|
 \ V /\__ \
  \_/ |___/


'''

# 프로그램 1차 버전

# result_list = ["", ""]
# people_list =[]
# def follower_cacl(first_people, second_people):
#     # 팔로우 계산한 후 result 리스트에 결과값 넣기
#     first_people_follower = first_people["follower_count"]
#     second_people_follower = second_people["follower_count"]

#     if first_people_follower > second_people_follower :
#         result_list[0] = first_people
#         result_list[1] = "A"
#     else:
#         result_list[0] = second_people
#         result_list[1] = "B"

#     return result_list

# def people_select(result_list, data, people_list):
#     answer_count = 0

#     while data != [] :
#         # 랜덤하기 두 인물을 뽑기
#         if result_list[0] == "":
#             people_list.append(data[random.randint(0, len(data))])
#             first_people = people_list[0]
#             data = [x for x in data if x not in people_list]
#             second_people = data[random.randint(0, len(data))]
#             people_list.append(second_people)
#             result_list = follower_cacl(first_people, second_people)

#         else:
#             first_people = result_list[0]
#             data = [x for x in data if x not in people_list]
#             second_people = data[random.randint(0, len(data))]
#             people_list.append(second_people)
#             result_list = follower_cacl(first_people, second_people)

#         print(f"첫번째 대상 A : {first_people['name']}, a {first_people['description']}, from {first_people['country']}")
#         print(vs)
#         print(f"두번째 대상 B : {second_people['name']}, a {second_people['description']}, from {second_people['country']}")

#         answer = input("어떤 대상의 팔로우가 더 많을까요? (A or B) : ").upper()
#         answer_count += 1

#         if answer == result_list[1] :
#             print('맞았습니다.')
#             print(f"선택한 대상 {answer}의 팔로우 수 : {result_list[0]['follower_count']}백만")
#             print(len(data))
#         else:
#             print(f'틀렸습니다. 당신의 점수 : {answer_count}점')
#             print(len(data))
#             return

# print(logo)
# people_select(result_list, data, people_list)


# # 프로그램 2차 버전

# result_list = ["","",""]

# def follower_cacl(first, second):
#     # 팔로우 계산한 후 result 리스트에 결과값 넣기

#     if first["follower_count"] > second["follower_count"] :
#         result_list = [first, second, "A"]
#     else:
#         result_list = [second, first, "B"]

#     return result_list

# def people_select(result_list, data):
#     answer_count = 0

#     while data != [] :
#         # 랜덤하기 두 인물을 뽑기
#         if result_list[0] == "":

#             first = data[random.randint(0, len(data))]
#             result_list[0] = first
#             data.remove(first)
#             second = data[random.randint(0, len(data))]
#             result_list[1] = second
#             data.remove(second)

#             result_list = follower_cacl(first, second)

#         else:
#             first = result_list[0]
#             second = data[random.randint(0, len(data))]
#             result_list[1] = second
#             data.remove(second)

#             result_list = follower_cacl(first, second)

#         print("\n")
#         print(f"첫번째 대상 A : {first['name']}, a {first['description']}, from {first['country']}")
#         print(vs)
#         print(f"두번째 대상 B : {second['name']}, a {second['description']}, from {second['country']}")

#         answer = input("어떤 대상의 팔로우가 더 많을까요? (A or B) : ").upper()
#         answer_count += 1

#         if answer == result_list[2] :
#             print(f'맞았습니다. 당신의 현재 점수 : {answer_count}')
#             # print(f"선택한 대상 {answer}의 팔로우 수 : {result_list[0]['follower_count']}백만")
#         else:
#             print(f'틀렸습니다. 당신의 점수 : {answer_count}점')
#             print(f"{result_list[0]['name']}의 팔로우 수 : {result_list[0]['follower_count']}백만")
#             print(f"{result_list[1]['name']}의 팔로우 수 : {result_list[1]['follower_count']}백만")
#             return

# print(logo)
# people_select(result_list, data)


# 프로그램 3차 버전(유데미 강좌 코드 일부 추가)

result_list = ["","",""]

def format_print(account):
    """data 리스트에서 추출한 딕셔너리 요소를 각각의 포멧에 맞게 출력하는 함수

    Args:
        account (dictionary): data 리스트에서 랜덤하게 추출된 딕셔너리 요소

    Returns:
        _str_: 딕셔너리 키 값을 일정하게 배열한 문자열을 출력함
    """
    return f"{account['name']}, a {account['description']}, from {account['country']}"

def follower_cacl(first, second):
    # 팔로우 계산한 후 result 리스트에 결과값 넣기

    if first["follower_count"] > second["follower_count"] :
        result_list = [first, second, "A"]
    else:
        result_list = [second, first, "B"]

    return result_list

def people_select(result_list, data):
    answer_count = 0
    second = random.choice(data)

    while answer_count != len(data) :
        # 랜덤하기 두 인물을 뽑기
        first = second
        second = random.choice(data)
        while first == second :
            second = random.choice(data)

        result_list = follower_cacl(first, second)


        print("\n")
        print(f"첫번째 대상 A : {format_print(first)}")
        print(vs)
        print(f"두번째 대상 B : {format_print(second)}")

        answer = input("어떤 대상의 팔로우가 더 많을까요? (A or B) : ").upper()
        answer_count += 1

        if answer == result_list[2] :
            print(f'맞았습니다. 당신의 현재 점수 : {answer_count}')
            # print(f"선택한 대상 {answer}의 팔로우 수 : {result_list[0]['follower_count']}백만")
        else:
            print(f'틀렸습니다. 당신의 점수 : {answer_count}점')
            print(f"{result_list[0]['name']}의 팔로우 수 : {result_list[0]['follower_count']}백만")
            print(f"{result_list[1]['name']}의 팔로우 수 : {result_list[1]['follower_count']}백만")
            return

print(logo)
people_select(result_list, data)



 _   _ _       _                 _
| | | (_)     | |               | |
| |_| |_  __ _| |__   ___ _ __  | |     _____      _____ _ __
|  _  | |/ _` | '_ \ / _ \ '__| | |    / _ \ \ /\ / / _ \ '__|
| | | | | (_| | | | |  __/ |    | |___| (_) \ V  V /  __/ |
\_| |_/_|\__, |_| |_|\___|_|    \_____/\___/ \_/\_/ \___|_|
          __/ |
         |___/
 _____
|  __ \
| |  \/ __ _ _ __ ___   ___
| | __ / _` | '_ ` _ \ / _ \
| |_\ \ (_| | | | | | |  __/
 \____/\__,_|_| |_| |_|\___|





첫번째 대상 A : Khloé Kardashian, a Reality TV personality and businesswoman, from United States

__   _____
\ \ / / __|
 \ V /\__   \_/ |___/



두번째 대상 B : Priyanka Chopra Jonas, a Actress and musician, from India
맞았습니다. 당신의 현재 점수 : 1


첫번째 대상 A : Priyanka Chopra Jonas, a Actress and musician, from India

__   _____
\ \ / / __|
 \ V /\__   \_/ |___/



두번째 대상 B : Ronaldinho, a Footballer, from Brasil
맞았습니다. 당신의 현재 점수 : 2


첫번째 대상 A : Ronaldinho, a Footballer, from Brasil

__   _____
\ \ / / __|
 \ V /\__   \_/ |___/



두번째 대상 B : Khloé Kardashian, a Reality TV personality and businesswoman, from United States
틀렸습니다. 당신의 점수 : 3점
Khloé Kardashian의 팔로우 수 : 108백만
Ronaldinho의 팔로우 수 : 51백만