Sort by

recency

|

2708 Discussions

|

  • + 0 comments

    Be Aware: After the n lines of phone book entries, there are an unknown number of lines of queries.

    One of solutions: while True: try: ... except EOFError: ...

  • + 0 comments

    This is my submission in JS

    let list = input.split('\n');
        let phoneBook = {};
        const n = parseInt(list[0]);
    
    
        for (let i = 1; i <= n; i++) {
            let [name, number] = list[i].split(' ');
            phoneBook[name] = number;
        }
    
        for (let i = n + 1; i < list.length; i++) {
            let name = list[i];
            if (name in phoneBook) {
                console.log(`${name}=${phoneBook[name]}`);
            } else {
                console.log('Not found');
            }
    *     }
    
  • + 0 comments

    im failing in test case1 but passing all the other ones im about to loose it

  • + 1 comment
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    n=int(input())
    k={}
    for i in range(n):
        name,ph=input().split()
        k[name]=int(ph)
    try:
        while True:
            inp=input()
            if inp in k:
                print(f'{inp}={k[inp]}')
            else:
                print('Not found')
    except EOFError:
        pass
    
  • + 0 comments

    Enter your code here. Read input from STDIN. Print output to STDOUT

    n = int(input()) phone_book = {} for _ in range(n): entry = input().split() name = entry[0] phone_number = entry[1] phone_book[name]=phone_number try: while True: query = input() if query in phone_book: print(f"{query}={phone_book[query]}") else: print("Not found") except EOFError: pass