Counting cards: Why is my code wrong and not submitting?

Please see my code:

def combinations(cards):
    import math
    cards = math.comb(52, cards)
    return cards

test = combinations(52)
print(test)

Your solution works from my end. Please try one of the following steps to move forward.

Click on the “Restart Step” button and force a refresh of your page with CTRL + F5 then try to paste the code in again.

or - Try the step in incognito or private mode.

or - Disable any/all extensions that interface with the freeCodeCamp website (such as Dark Mode, Ad Blockers, or Spellcheckers), and set your browser zoom level to 100%. Both of these factors can cause tests to fail erroneously.

or - Ensure your browser is up-to-date or try a different browser.

I hope one of these will work for you.

did you pick python at the top or is it still set to java, i was just looking at that daily thing and noticed it can be done in either java or python.

also this is probably wrong but i thought import is supposed to be done at the top of the main script? i didnt know you can do it inside a function.

Java is not JavaScript

the symantics makes no difference to me as i am just learning python and whether it says java or javascript at the top of the page beside python doesnt alter the outcome so lets stay focused.

you should still not say Java when it’s not Java, but JavaScript

imports are used usually at the top to have what is imported available in all the file, if you import it inside a function it will not be available outside the function

though you would be better creating your own topic for your questions

2 Likes

Programming is all about using the right semantics. It is important to use the correct words

1 Like

that was not a question. i was talking about the way he wrote his code. i always import at the top like i learned in one of the lessons on this site.

I wrote about that in my post, if you have more questions please create your own topic

yea well in this case it seems everyone was easily able to identify the fact that at the top it says js, and python so the fact i said java as an abbreviation is completely irrellivant. now if we were in a thread about java, or javascript and i failed to distinguish the difference I could understand what you mean but that was not the case and everyone knows exactly what i meant, making the correction completely symantical.

i dont have more questions, i was offering advice to other users, this is a forum. i remember when i started a couple weeks ago the simplist things stumped me. after getting help from you and others sometimes i take a break and see if i can help others, teaching is a great way to solidify things we’ve learned. it was not a question, when i have questions i create my own topic.

I am sorry, I misunderstood, I though you were confused about the different ways of using import

about Java vs JavaScript, it’s not semantics, they are two completely different languages, you should not confuse the two

2 Likes

yea i get that but in this case its completely irrelevant, the only thing relevant was that one option was python and one option was something else. im sure that makes more sense for everyone else but for me and in this python thread the fact that its java js or c++ makes no difference, the only thing that isnt symantics is that the important option is python.
but if its this much of a hassle ill just try to write it properly next time lol.

Using the correct technical words is very important

1 Like

okay. from now on i will try to use the correct terminoligy, even when i deem it irrellivant or unnessecary. i guess you are right, its definitely more professional to use the correct syntax, even if its irrellivant. i want to work in this field and i want people to take me seriously so i will adhere to your advice. sorry im so stubborn and argued with you lol…