Skip to content

Commit 691811d

Browse files
author
Amogh Singhal
authored
Update Python_Programming_Quiz.md
1 parent 5dd64c7 commit 691811d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Python_Programming_Quiz.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,3 +514,23 @@ a.1
514514
b.2
515515
c.7
516516
```
517+
518+
#### 31. How will you find, in a string, the first word that rhymes with ‘cake’?
519+
520+
For our purpose, we will use the `search()` function, and then use `group()` to get the output.
521+
522+
```
523+
>>> import re
524+
>>> rhyme=re.search('.ake','I would make a cake, but I hate to bake')
525+
>>> rhyme.group()
526+
‘make’
527+
```
528+
529+
#### 32. Write a regular expression that will accept an email id. Use the re module.
530+
531+
```
532+
>>> import re
533+
>>> e=re.search(r'[0-9a-zA-Z.]+@[a-zA-Z]+\.(com|co\.in)$','abc@gmail.com')
534+
>>> e.group()
535+
‘abc@gmail.com’
536+
```

0 commit comments

Comments
 (0)