Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # koodipaja 18.11.2021
- # viikkotehtävässä käytettävät tuotteet
- products = ["T1565_2020", "T2432_2019",
- "T8551_2018", "T3345_2019",
- "Y51372_2019", "Y76715_2017",
- "E98144_2018", "T7733_2020",
- "E7614_2021", "E9722_2017",
- "Y89875_2020", "T61287_2021",
- "E9152_2019", "T7749_2021"]
- # tämä kysytään käyttäjältä
- user_year = 2020
- # samaa split-koodia voi käyttää silmukassakin
- for text in products:
- parts = text.split("_")
- code = parts[0]
- year = parts[1]
- # jos user_year on sama kuin year => tulostetaan code
- print(f"{code} + {year}")
- # UUSI TIEDOSTO
- cafe = {
- "name": "Imaginary Cafe Oy",
- "website": "https://edu.frostbit.fi/sites/cafe",
- "categories": [
- "cafe",
- "tea",
- "lunch",
- "breakfast"
- ],
- "location": {
- "city": "Rovaniemi",
- "address": "Testikuja 22",
- "zip_code": "96200"
- }
- }
- location = cafe['location']
- city = location['city']
- print(city)
- city = cafe['location']['city']
- print(city)
- # UUSI TIEDOSTO, HUOM TÄMÄ KOODI EI OLE TOIMINTAKUNNOSSA
- # otetaan nimistä ylimääräiset välilyönnit pois (nimen alusta ja lopusta)
- people = [p.strip() for p in people]
- # people-muuttuja on tässä vaiheessa lista, joka koostuu henkilöiden kokonimistä
- #print(people)
- # tämä funktioon
- show_numbered_list("Alkuperäinen järjestys", people)
- print()
- people = sorted(people)
- # tämä funktioon
- for p in people:
- print(p)
Add Comment
Please, Sign In to add comment