'첼린지'에 해당되는 글 8건

퀴즈 

1. 스플릿 하기

2.url 만들기

3.url 검사

단!!! com 만되게 해놧다 
co.kr은 안됨!~!!
나중에 정규식 고쳐야한다~!

 

import requests
from bs4 import BeautifulSoup


def finding(biglist):
    country = input("#: ")
    if country.isdecimal():
        number = int(country)
        if number <= len(biglist):
            print("You chose", biglist[number][1])
            print("The currency code is", biglist[number][3].upper())
        else:
            print("Choose a number from the list.")
            return finding()
    else:
        print("That wasn\'t a number.")
        return finding()


def findurlcode():
    indeed_result = requests.get('https://www.iban.com/currency-codes')
    indeed_soup = BeautifulSoup(indeed_result.text, "html.parser")
    datalist = indeed_soup.find(
        "table", {"class": "table table-bordered downloads tablesorter"})
    pages = datalist.find_all('tr')
    biglist = []
    count = 0
    for i in pages[1:]:
        minilist = []
        minilist.append(count)
        for k in i:
            if k != "\n":
                data = str(k.string)
                if data.isdecimal():
                    minilist.append(int(data))
                else:
                    minilist.append(data[0] + data[1:].lower())
        if type(minilist[4]) == type(0):
            biglist.append(minilist)
            count += 1
    return biglist


def firstwork():
    biglist = findurlcode()
    for i in biglist:
        print("#", i[0], i[1])
    return biglist


def startgame():
    print("Hello! Please choose select a country by number:")
    biglist = firstwork()
    finding(biglist)
블로그 이미지

Or71nH

,

 

'''
Is Wed on 'days' list? True
The fourth item in 'days' is: Thu
['Mon', 'Tue', 'Wed', 'Thu','Fri', 'Sat', 'Sun', 'Sat']
['Tue', 'Wed', 'Thu', Fri', 'Sat', 'Sun', 'sat']
'''

'''
You need to create the following functions:
is_on_list
get_x
add_x
remove_x
'''


'''
DO NOT change anything inside of the "DO NOT TOUCH AREA"
해당 코드에서 빠진 함수가 있습니다. 위의 스크린과 같은 모습이 되도록 고쳐보세요.
반드시 위 표기된 함수들 (is_on_list. get_x. add_x. remove_x) 생성해야합니다.
DO NOT TOUCH 영역은 건들지마세요!
'''

퀴즈~~

"""
As you can see, the code is broken.
Create the missing functions, use default arguments.
Sometimes you have to use 'return' and sometimes you dont.
Start by creating the functions
"""

#^^^^^^^^^^^^^^^^^^^^^^^ Start ^^^^^^^^^^^^^^^^^^^^^^^^#
def is_on_list(inputlist, howdoUdo):
  if howdoUdo in inputlist:
    return True
  else:
    return False

def get_x(inputlist, howdoyoudo):
  return inputlist[howdoyoudo]

def add_x(inputlist, howUdo):
  return inputlist.append(howUdo)

def remove_x(inputlist, howyoudo):
  inputlist.remove(howyoudo)



# \/\/\/\/\/\/\  DO NOT TOUCH AREA  \/\/\/\/\/\/\ #

days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]

print("Is Wed on 'days' list?", is_on_list(days, "Wed"))

print("The fourth item in 'days' is:", get_x(days, 3))

add_x(days, "Sat")
print(days)

remove_x(days, "Mon")
print(days)


# /\/\/\/\/\/\/\ END DO NOT TOUCH AREA /\/\/\/\/\/\/\ #


 

이건 넘어가도록 하겟다~!

 

블로그 이미지

Or71nH

,

이런!! 틀렷다

 

첫날 가볍게 퀴즈 풀기~

 

블로그 이미지

Or71nH

,