first of all, don't use dict as a variable name, it's a built-in function and using it as a variable name you overwrite it.
second, when you read from file, it will read string, so
second, when you read from file, it will read string, so
l[0]!= 0
will be true ('0' != 0). Probably that is why you don't get your expected result