|
2 | 2 | "cells": [
|
3 | 3 | {
|
4 | 4 | "cell_type": "code",
|
| 5 | +<<<<<<< HEAD |
5 | 6 | "execution_count": 49,
|
6 | 7 | "metadata": {},
|
7 | 8 | "outputs": [
|
|
20 | 21 | "# 1,2,3,4,5,6,7,8,9\n",
|
21 | 22 | "# Then, the output should be:\n",
|
22 | 23 | "# 1,3,5,7,9\n",
|
| 24 | +======= |
| 25 | + "execution_count": 83, |
| 26 | + "metadata": {}, |
| 27 | + "outputs": [ |
| 28 | + { |
| 29 | + "data": { |
| 30 | + "text/plain": [ |
| 31 | + "'a,b,hola,que'" |
| 32 | + ] |
| 33 | + }, |
| 34 | + "execution_count": 83, |
| 35 | + "metadata": {}, |
| 36 | + "output_type": "execute_result" |
| 37 | + } |
| 38 | + ], |
| 39 | + "source": [ |
| 40 | + "# Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.\n", |
| 41 | + "# Suppose the following input is supplied to the program:\n", |
| 42 | + "# hello world and practice makes perfect and hello world again\n", |
| 43 | + "# Then, the output should be:\n", |
| 44 | + "# again and hello makes perfect practice world\n", |
| 45 | +>>>>>>> 860ad1bf6a0746d51c1cbae1094d60f93815ba4c |
23 | 46 | "\n",
|
| 47 | + "list_word = input('Write some words: ').split(' ')\n", |
24 | 48 | "\n",
|
| 49 | +<<<<<<< HEAD |
25 | 50 | "list_word = (input('Write some words: ')).split(',')\n",
|
26 | 51 | "new_list = []\n",
|
27 | 52 | "for word in list_word:\n",
|
28 | 53 | " if(int(word)%2 != 0):\n",
|
29 | 54 | " new_list.append(str(int(word)**2))\n",
|
30 | 55 | " \n",
|
31 | 56 | "print(','.join(new_list))"
|
| 57 | +======= |
| 58 | + "from collections import defaultdict\n", |
| 59 | + "\n", |
| 60 | + "temp_dict = defaultdict(int)\n", |
| 61 | + "for word in list_word:\n", |
| 62 | + " temp_dict[word] += 1\n", |
| 63 | + "\n", |
| 64 | + "temp_list = list(temp_dict.keys())\n", |
| 65 | + "\n", |
| 66 | + "temp_list.sort()\n", |
| 67 | + "\n", |
| 68 | + "','.join(temp_list)" |
| 69 | +>>>>>>> 860ad1bf6a0746d51c1cbae1094d60f93815ba4c |
32 | 70 | ]
|
33 | 71 | }
|
34 | 72 | ],
|
|
0 commit comments