Learn How to Work with Numbers and Strings by Implementing the Luhn Algorithm - Step 1

Tell us what’s happening:

I’m stuck just at the beginning and it makes me feel stupid.
“Start by declaring a function called main. Use the pass keyword to avoid an error.”
How shall I do that? How shall I use the pass keyword?
I’m trying any combination of the words given, but nothing sims to work

Your code so far


# User Editable Region

pass
main

# User Editable Region

Your browser information:

Lo user agent è: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/113.0

Challenge Information:

Learn How to Work with Numbers and Strings by Implementing the Luhn Algorithm - Step 1

2 Likes

you need to declare the main function, remember that functions are declare with the def keyword

This part of the course assumes that you have taken the previous course Learn String Manipulation by Building a Cipher and that you understand its precepts.

In step 50 of that previous course it features how to define a function

Step 50

A function is essentially a reusable block of code. You have already met some built-in functions, like print(), find() and len
(). But you can also define custom functions like this:

def function_name():
    <code>

A function declaration starts with the def keyword followed by the function name — a valid variable name — and a pair of parentheses. The declaration ends with a colon.
Right after your shift variable, declare a function called caesar and indent all the following lines to give your new function a body.

In step 82 of that same course it features the purpose of the keyword pass

Step 82

The pass keyword can be used as a placeholder for future code. It does not have any effect in your code but it can save you from errors you would get in case of incomplete code:

def foo():
    pass

Calling vigenere with 1 to encrypt and -1 to decrypt is fine but it might be a little bit cryptic. Create a new function called encrypt that takes message and key parameters, and use pass to fill the function body.

1 Like

Thanks, I didn’t find what to recall from the previous course and your answer is helping about method as well.

1 Like