Could make 'current_month' (an int) be equal to a specific index of my array 'month'? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Could make 'current_month' (an int) be equal to a specific index of my array 'month'?

Like current_month=1 == month[1] which would be Feb. I am trying to get used to scripting with python for the sake of Data Science for my webpage, and want to implement a "current month program" into one of the webpages.

12th Feb 2021, 8:53 PM
Michele Rene Machado
Michele Rene Machado - avatar
7 Answers
+ 1
So that month array holds name of months?
12th Feb 2021, 8:55 PM
Abhay
Abhay - avatar
+ 1
Michele Rene Machado so you want to check, 1== "Feb" or 0=="Jan" ?, If the array is month=["Jan", "Feb", " March"]
12th Feb 2021, 9:06 PM
Abhay
Abhay - avatar
+ 1
Yes if it is possible!! I still don't understand how will you do something like that . So i tried something , not sure if this is what you want. ----------------------- month=["Jan","Feb","March"] month=dict(enumerate(month)) c=month[1] if 1 in month else 0 print(c) dict(enumerate(month)) creates a dictionary with month values index as its key.
12th Feb 2021, 9:40 PM
Abhay
Abhay - avatar
0
Keep in mind I am a new learner and do struggle with this, but find it very fun.
12th Feb 2021, 8:54 PM
Michele Rene Machado
Michele Rene Machado - avatar
0
Yes!
12th Feb 2021, 8:56 PM
Michele Rene Machado
Michele Rene Machado - avatar
0
So there is no loop eligible to attach it to the index number, I gotta do it manually?
12th Feb 2021, 9:07 PM
Michele Rene Machado
Michele Rene Machado - avatar
0
Not completely sure, still waking up, thank you for the help, I will test this either tonight or tomorrow.
13th Feb 2021, 3:15 PM
Michele Rene Machado
Michele Rene Machado - avatar