Python:  Validate Credit Card Numbers Using For Loops (Ep. 2)
Channel: Christian Hur
Date: 2020-10-04

⭕ Overview
In this video, welcome to part two of the credit card number check exercise. We'll build upon the previous tutorial, focusing on verifying the validity of a credit card number using a for loop.

We'll start with a recap of the application's purpose, which is to check the validity of an eight-digit credit card number. The process will involve similar calculations to the first video, but this time, I'll demonstrate how to implement the logic using a for loop for more efficient and cleaner code.

☑️ The last digit of a credit card number is the check digit, which protects against transcription errors such as an error in a single digit or switching two digits. The following method is used to verify actual credit card numbers but, for simplicity, we will describe it for numbers with 8 digits instead of 16:

☑️ Starting from the rightmost digit, form the sum of every other digit. For example, if the credit card number is 4358 9795, then you form the sum 5 + 7 + 8 + 3 = 23.

☑️ Double each of the digits that were not included in the preceding step. Add all digits of the resulting numbers. For example, with the number given above, doubling the digits, starting with the next-to-last one, yields 18 18 10 8. Adding all digits in these values yields 1 + 8 + 1 + 8 + 1 + 0 + 8 = 27.
Add the sums of the two preceding steps. If the last digit of the result is 0, the number is valid. In our case, 23 + 27 = 50, so the number is valid.

☑️ Some sample valid numbers to try:
41235680, 12345674, 98765431, 11224458, 45645645

☑️ Write a program that implements this algorithm. The user should supply an 8-digit number, and you should print out whether the number is valid or invalid. 

By the end of this session, you'll have a deeper understanding of using loops in Python to handle repetitive tasks and ensure your code is both functional and optimized.

If you find this video helpful, please give it a thumbs up, share it with your friends, and subscribe to my channel for more tutorials and insights into programming. Your support helps me create more content to assist you in your learning journey. Thank you for watching!

⭕ Chapters
  0:00 - Introduction

⭕ About me
I am a Web instructor and author for Linkedin Learning (formerly Lynda.com), Packt, E-C Council, Udemy, and MC Press.

⭕ Visit my site: https://christianhur.com
⭕ My complete online training courses:
      ☑️ REST APIs & AJAX Operations Using Node, Express, and jQuery:  https://www.udemy.com/course/rest-apis-ajax-operations-using-node-express-and-jquery/?referralCode=A762AE70D9FD6A931F9B
https://www.udemy.com/course/build-clean-and-secure-php-web-apps-from-scratch/?referralCode=C200BB52F0C7153B93CC
      ☑️ Build Clean and Secure PHP Web Apps from Scratch: 
https://www.udemy.com/course/build-clean-and-secure-php-web-apps-from-scratch/?referralCode=C200BB52F0C7153B93CC
      ☑️ The DOM in JavaScript, jQuery, AngularJS, and React : https://www.linkedin.com/learning/the-dom-in-javascript-jquery-angularjs-and-react
      ☑️ Building JSF Web Applications with Java EE 7:  https://www.linkedin.com/learning/building-jsf-web-applications-with-java-ee-7
      ☑️ Troubleshooting Vue.js:  https://www.packtpub.com/application-development/troubleshooting-vuejs-video
      ☑️ Angular 7 New Features:  https://www.packtpub.com/web-development/angular-7-new-features-video
      ☑️ Full-Stack Web Development with Flask: https://www.packtpub.com/web-development/full-stack-web-development-flask-video
      ☑️ Full-Stack Web Development with Django & Angular 8: https://www.packtpub.com/web-development/full-stack-web-development-with-django-and-angular-8-video
      ☑️ Angular 9 New Features:  https://www.packtpub.com/web-development/angular-9-new-features-video

⭕ Check out my book:
Developing Business Applications for the Web: With HTML, CSS, JSP, PHP, ASP.NET, and JavaScript is available on Amazon and MC Press. 
      ☑️ Link:  https://www.mc-store.com/collections/christian-hur/products/developing-business-applications-for-the-web-with-html-css-jsp-php-asp-net-and-javascript