educative.io

Seems like compiler is not upto date

following line of code is failing
print(f"average_price = {average_price}")


Course: https://www.educative.io/collection/6586453712175104/5983100061876224
Lesson: https://www.educative.io/collection/page/6586453712175104/5983100061876224/4625231739617280

Hi @Naga_J_Sugguna !!
The code you provided seems correct, assuming that the variable average_price has been defined and calculated before this line. However, we are using an older version of Python 2.7, where the f-string formatting syntax is not available. You can achieve the same result using the .format() method for string formatting. Here’s how you can modify the code to get the expected output:

average_price = calculate_average_price()  # Replace with actual calculation
print('average_price = {}'.format(average_price))

The .format() method works similarly to f-strings and allows you to insert variable values into strings.
I hope it helps. Happy Learning :blush: