How to enumerate a list with fractions Python

1 Answer

0 votes
import fractions     
from itertools import *     

fr_start = fractions.Fraction(1, 4)     
fr_step = fractions.Fraction(1, 4)     

for i in zip(count(fr_start, fr_step), ['a', 'b', 'c', 'd']):         
    print('{}: {}'.format(*i))
    
    
   
'''
run:
 
1/4: a
1/2: b
3/4: c
1: d

'''

 



answered May 21, 2019 by avibootz

Related questions

3 answers 191 views
1 answer 181 views
2 answers 234 views
234 views asked May 11, 2019 by avibootz
1 answer 175 views
1 answer 149 views
...