I want to print something that looks like this:
Hello ¦ 7.16
This is the code I'm using
MyString = 'Hello'
MyFloat = 7.157777777
print "{} ¦ {0:.2f}".format(MyString, MyFloat)
But I get the error:
ValueError: cannot switch from automatic field numbering to manual field specification
If I try:
MyString = 'Hello'
MyFloat = 7.157777777
print "{s} ¦ {0:.2f}".format(MyString, MyFloat)
or str instead of s I get the error:
KeyError: 's'
Any ideas how I can print a variable string with a rounded float? Or is there something like %s that I should be using?