Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 13981

Python - start() and end() functions select tuple items

$
0
0

I made a very simple called Hangman and i have been trying to use .start() and .end() functions to get all the matches of user input.These functions return a tuple. for example;

text = 'test'hidden_word = list('_'*len(text))for m in re.finditer('t', text):     print('t found', m.start(), m.end())

Output >
('t found', 0, 1)
('t found', 3, 4)
My question is >how do I select items from the returned tuple?

.start()[1] Gives TypeError: 'int' object has no attribute '__getitem__'


Viewing all articles
Browse latest Browse all 13981

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>