Search code examples
pythonfuzzy-logic

Invalid syntax for format


Python 3.4 gives error to this statement. This is o print the cartesian product for fuzzy logic operations.

 print(f'The size of the relation will be: {len(self)}x{len(other)}')

I'm trying to perform the union, intersection and difference operations on fuzzy set.


Solution

  • python 3.4 does not support f-strings You could at emulate them if needed :

    def f(s):
        return s.format(**globals())
    
    answer = 'CRICKET'
    print(f('FOOTBALL OVER {ans}'))
    

    Edit: Its better to use .format as this wouldn't work directly for len(something)