python3 mystery

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Script started on Tue 15 Sep 2015 06:34:47 AM EDT
jude@iceberg:~$ cat gpe.py
import re
examplestring='''Jessica is 15 years old and Daniel is 27 years old
 Edward is 97 years old and his grandfather  Oscar is 102.'''
ages=re.findall(r'\d[1,3]',examplestring)
names=re.findall(r'[A,Z][a,z]*',examplestring)
print(names)
print(ages)
jude@iceberg:~$ python3 gpe.py
[]
[]
jude@iceberg:~$ exit
exit

Script done on Tue 15 Sep 2015 06:35:38 AM EDT
Why don't the names and ages lists get populated from exampleString then return names and ages in the examplestring vriable? This is a worked regular expressions exmple on http://www.pythonprogramming.net/ and as near as I can tell I keyed it in correctly.

 --

_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list



[Index of Archives]     [Linux Speakup]     [Fedora]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]