forked from Srinivas11789/AlgorithmNuggets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path101_17.py
More file actions
35 lines (24 loc) · 921 Bytes
/
101_17.py
File metadata and controls
35 lines (24 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Revision
# Regex library regexsearch string with both the pattern and the variable containing the string
# The variable returned contains only the instance, .group(0) contains the full match and .group(1) contains scrapped string
#!/bin/python
import sys,re
names = []
N = int(raw_input().strip())
for a0 in xrange(N):
firstName,emailID = raw_input().strip().split(' ')
firstName,emailID = [str(firstName),str(emailID)]
gmail = re.search("([a-zA-Z0-9]+)@gmail\.com",emailID)
if gmail:
name = gmail.group(1)
names.append(firstName)
# Bubble Sort Names for alphabetical order
for i in range(len(names)):
for j in range(len(names)-1):
temp = None
if names[j] > names[j+1]:
temp = names[j+1]
names[j+1] = names[j]
names[j] = temp
for item in names:
print item