# Tag Info

## Hot answers tagged credit.py

Accepted

### problem with pset6 python credit

One thing first, and has higher precedence than or. A or B and C is same as A or (B and C). Keep that in mind when combining the two. In Python, pretty much like in C, firstTwo == 51 or 52 or 53 or ...
• 20.9k
Accepted

### PSET6 credit.py, not able to import 'get_long_long'

Python doesn't have a long long type. You can use get_int to hold your credit card number.
• 18.7k
1 vote

### PSET 6 Credit More: always gives an output of INVALID

The Luhn's algorithm says you must add together the sum of the digits when multiplying by 2. So if your card number digit is 8, for example, 8 * 2 is 16, so you need to add 1+6 to your sum, not 16.
• 18.7k
1 vote
Accepted

### pset6 credit help with calculations in python

Unlike C, / will perform true floating point division in Python. To get integer division (and discard the remainder), use // instead. Regarding being stuck in the for loop, range(num) will loop all ...
• 950
1 vote
Accepted

### PSET6 Credit - checksum not giving the correct number

Looks like one step in Luhn's is missing: Multiply every other digit by 2, starting with the numberâ€™s second-to-last digit, and then add those productsâ€™ digits together.
• 28.4k
1 vote
Accepted

### Credit.py Runtime Errors

Python 3 separated integer division // and floating point division / operators. You probably want to use the former (note that it truncates the result, so you might have to use (length + 1) // 2 for ...
• 20.9k
1 vote
Accepted

### Pset6 Credit.py: Compiler returns 'Killed'

I don't see how while cardNo>0: could not cause an infinite loop. And don't use eval, it's evil.
• 20.9k
1 vote
Accepted

### Pset6 credit.py always outputs INVALID

Check this simple program, and see what happens when you get a float from the user using get_float() and then cast it to str. See what is wrong with it and how your program fails? import cs50 def ...
• 7,396

Only top scored, non community-wiki answers of a minimum length are eligible