Hello,
I am completely new to python and I'm taking a course online that has the following question:
When inputting a number, how can you verify if the digits of that number are divisible by 4?
For example, the input is input = "4007-6000-0000"
I'm having trouble converting this string of numbers to digits so I can add them up and see if they are divisible by 4.
The code I'm trying is the following:
I am completely new to python and I'm taking a course online that has the following question:
When inputting a number, how can you verify if the digits of that number are divisible by 4?
For example, the input is input = "4007-6000-0000"
I'm having trouble converting this string of numbers to digits so I can add them up and see if they are divisible by 4.
The code I'm trying is the following:
sum = 0 length = len(number) for i in range(0, length) : if number[1] != '-' : c += int(number[i])Any help would be greatly appreciated!
Larz60+ write Jan-11-2021, 11:04 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use code tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use code tags on future posts.