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 212 views
1 answer 189 views
2 answers 245 views
245 views asked May 11, 2019 by avibootz
1 answer 178 views
1 answer 154 views
...