python3 mystery

Jude DaShiell jdashiel at panix.com
Tue Sep 15 10:54:51 UTC 2015


Script started on Tue 15 Sep 2015 06:34:47 AM EDT
jude at 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 at iceberg:~$ python3 gpe.py
[]
[]
jude at 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.

  --




More information about the Blinux-list mailing list