ulope / pyformat.info

Single page cheat-sheet about Python string formatting
https://pyformat.info
MIT License
1.29k stars 137 forks source link

ValueError: '=' alignment not allowed in string format specifier #34

Closed quynguyen2303 closed 8 years ago

quynguyen2303 commented 8 years ago

Hi all,

I have an issue with string format specifier.

`def chaosThree():

Instruction

print('The program runs a chaos program with 3.9 and prints N output.')
print('With 3 formulas.')
# Get User's input
n = eval(input('How many times you want to loop? '))
x = eval(input('Enter a number: '))
# Print Label
print('{0:0} {1:0} {2:0} {3:0}'.format('Times','Formula1','Formula2', 'Formula3'))
# Loop to 10
for i in range(n):
    x1 = 3.9 * x * (1 - x) # Chaos formula - Logistic formula
    x2 = 3.9 * (x - x * x)
    x3 = 3.9 * x - 3.9 * x * x      
    print('{0:0} {1:7} {2:7} {3:7}'.format(i, x1, x2, x3))`

When I run this, it comes up with ValueError: '=' alignment not allowed in string format specifier at line print('{0:0} {1:0} {2:0} {3:0}'.format('Times','Formula1','Formula2', 'Formula3'))

When I deleted this String Format Specifier line, it worked well.

Do you have any idea about it? Sorry about the wrong place to ask. I don't know how to delete it.

Thanks.

zerok commented 8 years ago

No worries and I hope you will be able to solve your problem 😃

quynguyen2303 commented 8 years ago

Thanks a lot, I solved it. :)