If I have a text file name is python.txt
Python 2.0 was released on 16 October 2000 with many major new features, including a cycle-detecting garbage collector and support for Unicode.[43]
Python 3.0 was released on 3 December 2008. It was a major revision of the language that is not completely backward-compatible.[44] Many of its major features were backported to Python 2.6.x[45] and 2.7.x version series. Releases of Python 3 include the 2to3 utility, which automates (at least partially) the translation of Python 2 code to Python 3.[46]
I want to Find all instances of the python versions that has with .x in it. It should capture the followings: 3.5.x, 2.6.x, 2.7.x, etc. Then, print the result and the length of that list. How can I do? Thanks in advance. should I import this txt file at first? my codes are below:
import re
fp = open('python.txt', 'r')
s = fp.readline()
#print(s)
aList = re.findall('([-+]?\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?',s)
#print(aList)
for ss in aList:
#print(ss[0]+ss[2])
aNum = float((ss[0]+ss[2]))
#print(type(aNum))
print(aNum)
fp.close()