Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2019
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Unhappy New to Python I am trying to Create a loop to print the month number and name

    Can anyone out there help a novice out I am trying to Create a loop to print the month number and name


    pseudo code
    Months = [“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”]
    For x in range (1, 13)
    Do loop x in list.
    Print (“month {0} is {1}” Format X , month[x-1]
    End loop



    Months = [“January”, “February”, “March”, “April”, “May”, “June”, “July”, “August”, “September”, “October”, “November”, “December”]
    For x in range (1, 13)
    Print (“month {0} is {1}” Format X , month[x-1]
    Last edited by mcgraw927; Sep 19th, 2019 at 05:47 AM.

  2. #2
    Senior Coder Vege's Avatar
    Join Date
    Jan 2008
    Posts
    1,002
    Thanks
    22
    Thanked 136 Times in 135 Posts
    I'm an absolute novice too but heres nothing:
    PHP Code:
    # This Python file uses the following encoding: utf-8
    months = ["January""February""March""April""May""June""July""August""September""October""November""December"]
    for 
    x in range (12):
        print( 
    "Element Index["x"] Month "months[x] ) 

  3. Users who have thanked Vege for this post:

    mcgraw927 (Sep 19th, 2019)


 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •