Welcome to the new Africoders. What would love from me?

limistahlimistah Posts: 318
edited December 2017 in JavaScript
Hello everyone, welcome to the new version of Afrcoders.

Comments

  • mista_ceemista_cee Posts: 53
    edited October 2018
    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked
  • dhtmldhtml Posts: 1,019
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    that appears quite straight forward, are you experiencing any difficulties?
  • mista_ceemista_cee Posts: 53
    edited October 2018
    Yea...  Am experiencing difficulty in changing the buttons color via ajax
  • mista_ceemista_cee Posts: 53
    edited October 2018
    And am using codeigniter for this project.  I tried taking the code for the buttons and putting it in a separate file the loading it using $("id"). Load("url"); but didn't wrk
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018
    mista_cee wrote:Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clickedGotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jqueryCode:var button = $('.button)Handle on clickCode:button.on('click', function (event) { // Stops the event from carrying it out its default action

    // Useful for links and submit buttons from reloading 

    event.preventDefault(); 

    })

    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    Code:

    function prepareData () {
    return { // returns an object containing my data ready to be sent to the server
    username: $('input#username').val(),
    password: $('input#password').val()
    }
    }




    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.



    Code:button.on('click', function (event) { // Stops the event from carrying it out its default action

    // Useful for links and submit buttons from reloading  

    event.preventDefault(); 



    var self = $(this)

    data = prepareData()

    $.ajax({

     type: 'post',

     data: data,

     url: 'http://somewhere.com'    success: function (data) {

      // The request was successfull

      // Do other stuffs in here

      self.css({color: 'red', background: 'white'}

     },

     error: function (error) {

      // Handle your error here

     }

    })

    })

    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • limistahlimistah Posts: 318
    edited October 2018

    mista_cee wrote:

    Hey....  Am working on a site on my local machine and I want to create a functionality which the administration has the ability to click a button which triggers a request via Ajax to update a particular data in the update and then dynamically change the color of Burton clicked


    Gotcha!!!!!



    I don't know how CodeIgniter works, but what I know is applicable in every framework is this (kinda like a flow chart):



    Get the button using jquery

    Code:

    var button = $('.button)


    Handle on click

    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading 
    event.preventDefault(); 
    })




    Get the data you want to send to your api, usually I do have a function in all my component called prepareData when I need to post data to the API

    Something like this



    function prepareData () {

    return { // returns an object containing my data ready to be sent to the server

     username: $('input#username').val(),

     password: $('input#password').val()

    }

    }



    Note that the function returns an object



    Then you can now go back to your button event handler and send your request to the server.





    Code:

    button.on('click', function (event) {
    // Stops the event from carrying it out its default action
    // Useful for links and submit buttons from reloading  
    event.preventDefault(); 

    var self = $(this)
    data = prepareData()
    $.ajax({
     type: 'post',
     data: data,
     url: 'http://somewhere.com'
       success: function (data) {
      // The request was successfull
      // Do other stuffs in here
      self.css({color: 'red', background: 'white'}
     },
     error: function (error) {
      // Handle your error here
     }
    })
    })




    The above code should be something you are looking for!!!







    PEACE!!!
  • dhtmldhtml Posts: 1,019
    edited October 2018
    So far so good. nice ride. Just some little typing mistakes.Vote up! Vote down!Points: 0You voted ‘up’Top Wed, 11/22/2017 - 22:41(Reply to #16)#174kingsFestus Thanks. :)

    I'll proof read the write-up again, i've been very busy that's the reason for the delay in the tutorial.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/30/2017 - 00:06(Reply to #17)#18FestusYou're good boss.

    I love your work.





    I am hoping I will one day become smart and learned enough to serve your likes and programming needs of the greater populace.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 05:36(Reply to #18)#194kings...Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 17:03#204kingsLists

    List function in python is denoted as [].

    This square brackets contains all elements of the list, separated with comma(,).

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']



    That's an example of list assignment.



    To get length or Number of items in a list.



    >>> len(mylist)

    5

    I haven't discussed this, but len() function can also be used to get the length of a string too.



    List Indexing

    We can index position of elements of a list in python.

    Python's indexing start from 0.

    Therefore index 0 in the list created above is 'Lagos'

    Illustration:



    >>> mylist[0]

    'Lagos'

    >>> mylist[1]

    'Ogun'



    So we've seen how list are indexed.

    More to indeixng, we can also index a list from last position without counting the number of elements by using -1.

    Example:



    >>> mylist[-1]

    'Zamfara'

    Therefore:

    >>> mylist[-2]

    'AkwaIbom'



    List Slicing

    The concept behind list slicing is to cut out and return part of a list.

    Using [start:stop] method, where start is the value to index from and stop is the value to stop at.

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0:3]





    Notice that index 3 is 'AkwaIbom' but the return didn't include this.

    The concept behind that is that python start slicing your list from your first index and stop just before your last index. In this case our first and last index is 0 and 3 respectively.



    Also we can add an increment parameter to the list to increment how elements in the list are to be sliced

    So we use [start:stop:increment]



    >>> mylist[0:-1:2]



    So we can see the list is meant to start at index 0 and stop at the last index[-1] but we added an increment parameter which is to increase the slice of element by 2.

    Therefore, when it starts at index 0, it goes to the second element, and does same for the next and so on depending on the length of the list and the stop parameter.



    Mutability of List:

    This simply means that list element can be changed once created.

    For example:



    >>> mylist =[ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0] = 'Borno'

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    We can see above how we changed the first element of the list from 'Lagos' to 'Borno'



    We can also change element slices of the list at the same time.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[1:3] = 'Jos', 'Kwara'

    >>> mylist

    [ 'Borno', 'Jos', 'Kwara', 'AkwaIbom', 'Zamfara']



    List elements can be of multiple data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> print(mylist)

    [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]



    We can also see that our list can have a sub-list too.



    Now let's look at some List functions:

    min

    This function returns the minimum value of elements in the list. And is of this format==> min(list)

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> min(mylist)

    1



    >>> mylist2 = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> min(mylist2)

    'AkwaIbom'



    We can also see that for string, min finds the minimum alphabetically.



    However we can't use min for different data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> min(mylist)



    Traceback (most recent call last):

    File "<pyshell#33>", line 1, in <module>

    min(mylist)

    TypeError: unorderable types: str() < int()





    We would discuss errors later on in this tutorial.



    append

    This is another function of python's list. It's function is to add item to an already existing python list.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist.append('Kogi')

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']





    extend

    Extend function is similar to append, but extend adds a list or an iterable item to an existing list.



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']

    >>> east = [ 'Ebonyi', 'Anambra', 'Abia']

    >>> mylist.extend(east)

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi', 'Ebonyi', 'Anambra', 'Abia']





    sort

    As the name implies, this sorts an element in a list.

    For example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.sort()

    >>> print(mylist)

    [1, 2, 91, 300, 419, 699]



    reverse

    This reverse items in a list.

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.reverse()

    >>> print(mylist)

    [1, 419, 91, 2, 699, 300]



    count

    This function counts number of times an item appears in a list.



    >>> mylist = [1,2,4,5,1,5,2,4,5,8,3,]

    >>> mylist.count(1)

    2
  • dhtmldhtml Posts: 1,019
    edited October 2018
    So far so good. nice ride. Just some little typing mistakes.Vote up! Vote down!Points: 0You voted ‘up’Top Wed, 11/22/2017 - 22:41(Reply to #16)#174kingsFestus Thanks. :)

    I'll proof read the write-up again, i've been very busy that's the reason for the delay in the tutorial.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/30/2017 - 00:06(Reply to #17)#18FestusYou're good boss.

    I love your work.





    I am hoping I will one day become smart and learned enough to serve your likes and programming needs of the greater populace.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 05:36(Reply to #18)#194kings...Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 17:03#204kingsLists

    List function in python is denoted as [].

    This square brackets contains all elements of the list, separated with comma(,).

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']



    That's an example of list assignment.



    To get length or Number of items in a list.



    >>> len(mylist)

    5

    I haven't discussed this, but len() function can also be used to get the length of a string too.



    List Indexing

    We can index position of elements of a list in python.

    Python's indexing start from 0.

    Therefore index 0 in the list created above is 'Lagos'

    Illustration:



    >>> mylist[0]

    'Lagos'

    >>> mylist[1]

    'Ogun'



    So we've seen how list are indexed.

    More to indeixng, we can also index a list from last position without counting the number of elements by using -1.

    Example:



    >>> mylist[-1]

    'Zamfara'

    Therefore:

    >>> mylist[-2]

    'AkwaIbom'



    List Slicing

    The concept behind list slicing is to cut out and return part of a list.

    Using [start:stop] method, where start is the value to index from and stop is the value to stop at.

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0:3]





    Notice that index 3 is 'AkwaIbom' but the return didn't include this.

    The concept behind that is that python start slicing your list from your first index and stop just before your last index. In this case our first and last index is 0 and 3 respectively.



    Also we can add an increment parameter to the list to increment how elements in the list are to be sliced

    So we use [start:stop:increment]



    >>> mylist[0:-1:2]



    So we can see the list is meant to start at index 0 and stop at the last index[-1] but we added an increment parameter which is to increase the slice of element by 2.

    Therefore, when it starts at index 0, it goes to the second element, and does same for the next and so on depending on the length of the list and the stop parameter.



    Mutability of List:

    This simply means that list element can be changed once created.

    For example:



    >>> mylist =[ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0] = 'Borno'

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    We can see above how we changed the first element of the list from 'Lagos' to 'Borno'



    We can also change element slices of the list at the same time.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[1:3] = 'Jos', 'Kwara'

    >>> mylist

    [ 'Borno', 'Jos', 'Kwara', 'AkwaIbom', 'Zamfara']



    List elements can be of multiple data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> print(mylist)

    [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]



    We can also see that our list can have a sub-list too.



    Now let's look at some List functions:

    min

    This function returns the minimum value of elements in the list. And is of this format==> min(list)

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> min(mylist)

    1



    >>> mylist2 = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> min(mylist2)

    'AkwaIbom'



    We can also see that for string, min finds the minimum alphabetically.



    However we can't use min for different data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> min(mylist)



    Traceback (most recent call last):

    File "<pyshell#33>", line 1, in <module>

    min(mylist)

    TypeError: unorderable types: str() < int()





    We would discuss errors later on in this tutorial.



    append

    This is another function of python's list. It's function is to add item to an already existing python list.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist.append('Kogi')

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']





    extend

    Extend function is similar to append, but extend adds a list or an iterable item to an existing list.



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']

    >>> east = [ 'Ebonyi', 'Anambra', 'Abia']

    >>> mylist.extend(east)

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi', 'Ebonyi', 'Anambra', 'Abia']





    sort

    As the name implies, this sorts an element in a list.

    For example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.sort()

    >>> print(mylist)

    [1, 2, 91, 300, 419, 699]



    reverse

    This reverse items in a list.

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.reverse()

    >>> print(mylist)

    [1, 419, 91, 2, 699, 300]



    count

    This function counts number of times an item appears in a list.



    >>> mylist = [1,2,4,5,1,5,2,4,5,8,3,]

    >>> mylist.count(1)

    2So far so good. nice ride. Just some little typing mistakes.Vote up! Vote down!Points: 0You voted ‘up’Top Wed, 11/22/2017 - 22:41(Reply to #16)#174kingsFestus Thanks. :)

    I'll proof read the write-up again, i've been very busy that's the reason for the delay in the tutorial.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/30/2017 - 00:06(Reply to #17)#18FestusYou're good boss.

    I love your work.





    I am hoping I will one day become smart and learned enough to serve your likes and programming needs of the greater populace.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 05:36(Reply to #18)#194kings...Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 17:03#204kingsLists

    List function in python is denoted as [].

    This square brackets contains all elements of the list, separated with comma(,).

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']



    That's an example of list assignment.



    To get length or Number of items in a list.



    >>> len(mylist)

    5

    I haven't discussed this, but len() function can also be used to get the length of a string too.



    List Indexing

    We can index position of elements of a list in python.

    Python's indexing start from 0.

    Therefore index 0 in the list created above is 'Lagos'

    Illustration:



    >>> mylist[0]

    'Lagos'

    >>> mylist[1]

    'Ogun'



    So we've seen how list are indexed.

    More to indeixng, we can also index a list from last position without counting the number of elements by using -1.

    Example:



    >>> mylist[-1]

    'Zamfara'

    Therefore:

    >>> mylist[-2]

    'AkwaIbom'



    List Slicing

    The concept behind list slicing is to cut out and return part of a list.

    Using [start:stop] method, where start is the value to index from and stop is the value to stop at.

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0:3]





    Notice that index 3 is 'AkwaIbom' but the return didn't include this.

    The concept behind that is that python start slicing your list from your first index and stop just before your last index. In this case our first and last index is 0 and 3 respectively.



    Also we can add an increment parameter to the list to increment how elements in the list are to be sliced

    So we use [start:stop:increment]



    >>> mylist[0:-1:2]



    So we can see the list is meant to start at index 0 and stop at the last index[-1] but we added an increment parameter which is to increase the slice of element by 2.

    Therefore, when it starts at index 0, it goes to the second element, and does same for the next and so on depending on the length of the list and the stop parameter.



    Mutability of List:

    This simply means that list element can be changed once created.

    For example:



    >>> mylist =[ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0] = 'Borno'

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    We can see above how we changed the first element of the list from 'Lagos' to 'Borno'



    We can also change element slices of the list at the same time.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[1:3] = 'Jos', 'Kwara'

    >>> mylist

    [ 'Borno', 'Jos', 'Kwara', 'AkwaIbom', 'Zamfara']



    List elements can be of multiple data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> print(mylist)

    [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]



    We can also see that our list can have a sub-list too.



    Now let's look at some List functions:

    min

    This function returns the minimum value of elements in the list. And is of this format==> min(list)

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> min(mylist)

    1



    >>> mylist2 = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> min(mylist2)

    'AkwaIbom'



    We can also see that for string, min finds the minimum alphabetically.



    However we can't use min for different data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> min(mylist)



    Traceback (most recent call last):

    File "<pyshell#33>", line 1, in <module>

    min(mylist)

    TypeError: unorderable types: str() < int()





    We would discuss errors later on in this tutorial.



    append

    This is another function of python's list. It's function is to add item to an already existing python list.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist.append('Kogi')

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']





    extend

    Extend function is similar to append, but extend adds a list or an iterable item to an existing list.



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']

    >>> east = [ 'Ebonyi', 'Anambra', 'Abia']

    >>> mylist.extend(east)

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi', 'Ebonyi', 'Anambra', 'Abia']





    sort

    As the name implies, this sorts an element in a list.

    For example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.sort()

    >>> print(mylist)

    [1, 2, 91, 300, 419, 699]



    reverse

    This reverse items in a list.

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.reverse()

    >>> print(mylist)

    [1, 419, 91, 2, 699, 300]



    count

    This function counts number of times an item appears in a list.



    >>> mylist = [1,2,4,5,1,5,2,4,5,8,3,]

    >>> mylist.count(1)

    2So far so good. nice ride. Just some little typing mistakes.Vote up! Vote down!Points: 0You voted ‘up’Top Wed, 11/22/2017 - 22:41(Reply to #16)#174kingsFestus Thanks. :)

    I'll proof read the write-up again, i've been very busy that's the reason for the delay in the tutorial.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/30/2017 - 00:06(Reply to #17)#18FestusYou're good boss.

    I love your work.





    I am hoping I will one day become smart and learned enough to serve your likes and programming needs of the greater populace.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 05:36(Reply to #18)#194kings...Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 17:03#204kingsLists

    List function in python is denoted as [].

    This square brackets contains all elements of the list, separated with comma(,).

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']



    That's an example of list assignment.



    To get length or Number of items in a list.



    >>> len(mylist)

    5

    I haven't discussed this, but len() function can also be used to get the length of a string too.



    List Indexing

    We can index position of elements of a list in python.

    Python's indexing start from 0.

    Therefore index 0 in the list created above is 'Lagos'

    Illustration:



    >>> mylist[0]

    'Lagos'

    >>> mylist[1]

    'Ogun'



    So we've seen how list are indexed.

    More to indeixng, we can also index a list from last position without counting the number of elements by using -1.

    Example:



    >>> mylist[-1]

    'Zamfara'

    Therefore:

    >>> mylist[-2]

    'AkwaIbom'



    List Slicing

    The concept behind list slicing is to cut out and return part of a list.

    Using [start:stop] method, where start is the value to index from and stop is the value to stop at.

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0:3]





    Notice that index 3 is 'AkwaIbom' but the return didn't include this.

    The concept behind that is that python start slicing your list from your first index and stop just before your last index. In this case our first and last index is 0 and 3 respectively.



    Also we can add an increment parameter to the list to increment how elements in the list are to be sliced

    So we use [start:stop:increment]



    >>> mylist[0:-1:2]



    So we can see the list is meant to start at index 0 and stop at the last index[-1] but we added an increment parameter which is to increase the slice of element by 2.

    Therefore, when it starts at index 0, it goes to the second element, and does same for the next and so on depending on the length of the list and the stop parameter.



    Mutability of List:

    This simply means that list element can be changed once created.

    For example:



    >>> mylist =[ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0] = 'Borno'

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    We can see above how we changed the first element of the list from 'Lagos' to 'Borno'



    We can also change element slices of the list at the same time.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[1:3] = 'Jos', 'Kwara'

    >>> mylist

    [ 'Borno', 'Jos', 'Kwara', 'AkwaIbom', 'Zamfara']



    List elements can be of multiple data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> print(mylist)

    [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]



    We can also see that our list can have a sub-list too.



    Now let's look at some List functions:

    min

    This function returns the minimum value of elements in the list. And is of this format==> min(list)

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> min(mylist)

    1



    >>> mylist2 = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> min(mylist2)

    'AkwaIbom'



    We can also see that for string, min finds the minimum alphabetically.



    However we can't use min for different data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> min(mylist)



    Traceback (most recent call last):

    File "<pyshell#33>", line 1, in <module>

    min(mylist)

    TypeError: unorderable types: str() < int()





    We would discuss errors later on in this tutorial.



    append

    This is another function of python's list. It's function is to add item to an already existing python list.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist.append('Kogi')

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']





    extend

    Extend function is similar to append, but extend adds a list or an iterable item to an existing list.



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']

    >>> east = [ 'Ebonyi', 'Anambra', 'Abia']

    >>> mylist.extend(east)

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi', 'Ebonyi', 'Anambra', 'Abia']





    sort

    As the name implies, this sorts an element in a list.

    For example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.sort()

    >>> print(mylist)

    [1, 2, 91, 300, 419, 699]



    reverse

    This reverse items in a list.

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.reverse()

    >>> print(mylist)

    [1, 419, 91, 2, 699, 300]



    count

    This function counts number of times an item appears in a list.



    >>> mylist = [1,2,4,5,1,5,2,4,5,8,3,]

    >>> mylist.count(1)

    2So far so good. nice ride. Just some little typing mistakes.Vote up! Vote down!Points: 0You voted ‘up’Top Wed, 11/22/2017 - 22:41(Reply to #16)#174kingsFestus Thanks. :)

    I'll proof read the write-up again, i've been very busy that's the reason for the delay in the tutorial.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/30/2017 - 00:06(Reply to #17)#18FestusYou're good boss.

    I love your work.





    I am hoping I will one day become smart and learned enough to serve your likes and programming needs of the greater populace.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 05:36(Reply to #18)#194kings...Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 17:03#204kingsLists

    List function in python is denoted as [].

    This square brackets contains all elements of the list, separated with comma(,).

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']



    That's an example of list assignment.



    To get length or Number of items in a list.



    >>> len(mylist)

    5

    I haven't discussed this, but len() function can also be used to get the length of a string too.



    List Indexing

    We can index position of elements of a list in python.

    Python's indexing start from 0.

    Therefore index 0 in the list created above is 'Lagos'

    Illustration:



    >>> mylist[0]

    'Lagos'

    >>> mylist[1]

    'Ogun'



    So we've seen how list are indexed.

    More to indeixng, we can also index a list from last position without counting the number of elements by using -1.

    Example:



    >>> mylist[-1]

    'Zamfara'

    Therefore:

    >>> mylist[-2]

    'AkwaIbom'



    List Slicing

    The concept behind list slicing is to cut out and return part of a list.

    Using [start:stop] method, where start is the value to index from and stop is the value to stop at.

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0:3]





    Notice that index 3 is 'AkwaIbom' but the return didn't include this.

    The concept behind that is that python start slicing your list from your first index and stop just before your last index. In this case our first and last index is 0 and 3 respectively.



    Also we can add an increment parameter to the list to increment how elements in the list are to be sliced

    So we use [start:stop:increment]



    >>> mylist[0:-1:2]



    So we can see the list is meant to start at index 0 and stop at the last index[-1] but we added an increment parameter which is to increase the slice of element by 2.

    Therefore, when it starts at index 0, it goes to the second element, and does same for the next and so on depending on the length of the list and the stop parameter.



    Mutability of List:

    This simply means that list element can be changed once created.

    For example:



    >>> mylist =[ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0] = 'Borno'

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    We can see above how we changed the first element of the list from 'Lagos' to 'Borno'



    We can also change element slices of the list at the same time.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[1:3] = 'Jos', 'Kwara'

    >>> mylist

    [ 'Borno', 'Jos', 'Kwara', 'AkwaIbom', 'Zamfara']



    List elements can be of multiple data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> print(mylist)

    [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]



    We can also see that our list can have a sub-list too.



    Now let's look at some List functions:

    min

    This function returns the minimum value of elements in the list. And is of this format==> min(list)

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> min(mylist)

    1



    >>> mylist2 = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> min(mylist2)

    'AkwaIbom'



    We can also see that for string, min finds the minimum alphabetically.



    However we can't use min for different data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> min(mylist)



    Traceback (most recent call last):

    File "<pyshell#33>", line 1, in <module>

    min(mylist)

    TypeError: unorderable types: str() < int()





    We would discuss errors later on in this tutorial.



    append

    This is another function of python's list. It's function is to add item to an already existing python list.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist.append('Kogi')

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']





    extend

    Extend function is similar to append, but extend adds a list or an iterable item to an existing list.



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']

    >>> east = [ 'Ebonyi', 'Anambra', 'Abia']

    >>> mylist.extend(east)

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi', 'Ebonyi', 'Anambra', 'Abia']





    sort

    As the name implies, this sorts an element in a list.

    For example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.sort()

    >>> print(mylist)

    [1, 2, 91, 300, 419, 699]



    reverse

    This reverse items in a list.

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.reverse()

    >>> print(mylist)

    [1, 419, 91, 2, 699, 300]



    count

    This function counts number of times an item appears in a list.



    >>> mylist = [1,2,4,5,1,5,2,4,5,8,3,]

    >>> mylist.count(1)

    2So far so good. nice ride. Just some little typing mistakes.Vote up! Vote down!Points: 0You voted ‘up’Top Wed, 11/22/2017 - 22:41(Reply to #16)#174kingsFestus Thanks. :)

    I'll proof read the write-up again, i've been very busy that's the reason for the delay in the tutorial.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/30/2017 - 00:06(Reply to #17)#18FestusYou're good boss.

    I love your work.





    I am hoping I will one day become smart and learned enough to serve your likes and programming needs of the greater populace.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 05:36(Reply to #18)#194kings...Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 17:03#204kingsLists

    List function in python is denoted as [].

    This square brackets contains all elements of the list, separated with comma(,).

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']



    That's an example of list assignment.



    To get length or Number of items in a list.



    >>> len(mylist)

    5

    I haven't discussed this, but len() function can also be used to get the length of a string too.



    List Indexing

    We can index position of elements of a list in python.

    Python's indexing start from 0.

    Therefore index 0 in the list created above is 'Lagos'

    Illustration:



    >>> mylist[0]

    'Lagos'

    >>> mylist[1]

    'Ogun'



    So we've seen how list are indexed.

    More to indeixng, we can also index a list from last position without counting the number of elements by using -1.

    Example:



    >>> mylist[-1]

    'Zamfara'

    Therefore:

    >>> mylist[-2]

    'AkwaIbom'



    List Slicing

    The concept behind list slicing is to cut out and return part of a list.

    Using [start:stop] method, where start is the value to index from and stop is the value to stop at.

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0:3]





    Notice that index 3 is 'AkwaIbom' but the return didn't include this.

    The concept behind that is that python start slicing your list from your first index and stop just before your last index. In this case our first and last index is 0 and 3 respectively.



    Also we can add an increment parameter to the list to increment how elements in the list are to be sliced

    So we use [start:stop:increment]



    >>> mylist[0:-1:2]



    So we can see the list is meant to start at index 0 and stop at the last index[-1] but we added an increment parameter which is to increase the slice of element by 2.

    Therefore, when it starts at index 0, it goes to the second element, and does same for the next and so on depending on the length of the list and the stop parameter.



    Mutability of List:

    This simply means that list element can be changed once created.

    For example:



    >>> mylist =[ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0] = 'Borno'

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    We can see above how we changed the first element of the list from 'Lagos' to 'Borno'



    We can also change element slices of the list at the same time.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[1:3] = 'Jos', 'Kwara'

    >>> mylist

    [ 'Borno', 'Jos', 'Kwara', 'AkwaIbom', 'Zamfara']



    List elements can be of multiple data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> print(mylist)

    [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]



    We can also see that our list can have a sub-list too.



    Now let's look at some List functions:

    min

    This function returns the minimum value of elements in the list. And is of this format==> min(list)

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> min(mylist)

    1



    >>> mylist2 = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> min(mylist2)

    'AkwaIbom'



    We can also see that for string, min finds the minimum alphabetically.



    However we can't use min for different data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> min(mylist)



    Traceback (most recent call last):

    File "<pyshell#33>", line 1, in <module>

    min(mylist)

    TypeError: unorderable types: str() < int()





    We would discuss errors later on in this tutorial.



    append

    This is another function of python's list. It's function is to add item to an already existing python list.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist.append('Kogi')

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']





    extend

    Extend function is similar to append, but extend adds a list or an iterable item to an existing list.



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']

    >>> east = [ 'Ebonyi', 'Anambra', 'Abia']

    >>> mylist.extend(east)

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi', 'Ebonyi', 'Anambra', 'Abia']





    sort

    As the name implies, this sorts an element in a list.

    For example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.sort()

    >>> print(mylist)

    [1, 2, 91, 300, 419, 699]



    reverse

    This reverse items in a list.

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.reverse()

    >>> print(mylist)

    [1, 419, 91, 2, 699, 300]



    count

    This function counts number of times an item appears in a list.



    >>> mylist = [1,2,4,5,1,5,2,4,5,8,3,]

    >>> mylist.count(1)

    2So far so good. nice ride. Just some little typing mistakes.Vote up! Vote down!Points: 0You voted ‘up’Top Wed, 11/22/2017 - 22:41(Reply to #16)#174kingsFestus Thanks. :)

    I'll proof read the write-up again, i've been very busy that's the reason for the delay in the tutorial.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/30/2017 - 00:06(Reply to #17)#18FestusYou're good boss.

    I love your work.





    I am hoping I will one day become smart and learned enough to serve your likes and programming needs of the greater populace.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 05:36(Reply to #18)#194kings...Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 17:03#204kingsLists

    List function in python is denoted as [].

    This square brackets contains all elements of the list, separated with comma(,).

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']



    That's an example of list assignment.



    To get length or Number of items in a list.



    >>> len(mylist)

    5

    I haven't discussed this, but len() function can also be used to get the length of a string too.



    List Indexing

    We can index position of elements of a list in python.

    Python's indexing start from 0.

    Therefore index 0 in the list created above is 'Lagos'

    Illustration:



    >>> mylist[0]

    'Lagos'

    >>> mylist[1]

    'Ogun'



    So we've seen how list are indexed.

    More to indeixng, we can also index a list from last position without counting the number of elements by using -1.

    Example:



    >>> mylist[-1]

    'Zamfara'

    Therefore:

    >>> mylist[-2]

    'AkwaIbom'



    List Slicing

    The concept behind list slicing is to cut out and return part of a list.

    Using [start:stop] method, where start is the value to index from and stop is the value to stop at.

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0:3]





    Notice that index 3 is 'AkwaIbom' but the return didn't include this.

    The concept behind that is that python start slicing your list from your first index and stop just before your last index. In this case our first and last index is 0 and 3 respectively.



    Also we can add an increment parameter to the list to increment how elements in the list are to be sliced

    So we use [start:stop:increment]



    >>> mylist[0:-1:2]



    So we can see the list is meant to start at index 0 and stop at the last index[-1] but we added an increment parameter which is to increase the slice of element by 2.

    Therefore, when it starts at index 0, it goes to the second element, and does same for the next and so on depending on the length of the list and the stop parameter.



    Mutability of List:

    This simply means that list element can be changed once created.

    For example:



    >>> mylist =[ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0] = 'Borno'

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    We can see above how we changed the first element of the list from 'Lagos' to 'Borno'



    We can also change element slices of the list at the same time.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[1:3] = 'Jos', 'Kwara'

    >>> mylist

    [ 'Borno', 'Jos', 'Kwara', 'AkwaIbom', 'Zamfara']



    List elements can be of multiple data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> print(mylist)

    [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]



    We can also see that our list can have a sub-list too.



    Now let's look at some List functions:

    min

    This function returns the minimum value of elements in the list. And is of this format==> min(list)

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> min(mylist)

    1



    >>> mylist2 = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> min(mylist2)

    'AkwaIbom'



    We can also see that for string, min finds the minimum alphabetically.



    However we can't use min for different data types.

    For example:



    >>> mylist = [1000, 'Nigeria', 9.11, ['Dhtml', 'Festus', 'Seun']]

    >>> min(mylist)



    Traceback (most recent call last):

    File "<pyshell#33>", line 1, in <module>

    min(mylist)

    TypeError: unorderable types: str() < int()





    We would discuss errors later on in this tutorial.



    append

    This is another function of python's list. It's function is to add item to an already existing python list.

    For example:



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist.append('Kogi')

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']





    extend

    Extend function is similar to append, but extend adds a list or an iterable item to an existing list.



    >>> mylist = [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi']

    >>> east = [ 'Ebonyi', 'Anambra', 'Abia']

    >>> mylist.extend(east)

    >>> print(mylist)

    [ 'Borno', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara', 'Kogi', 'Ebonyi', 'Anambra', 'Abia']





    sort

    As the name implies, this sorts an element in a list.

    For example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.sort()

    >>> print(mylist)

    [1, 2, 91, 300, 419, 699]



    reverse

    This reverse items in a list.

    Example:



    >>> mylist = [300,699,2,91,419, 1]

    >>> mylist.reverse()

    >>> print(mylist)

    [1, 419, 91, 2, 699, 300]



    count

    This function counts number of times an item appears in a list.



    >>> mylist = [1,2,4,5,1,5,2,4,5,8,3,]

    >>> mylist.count(1)

    2So far so good. nice ride. Just some little typing mistakes.Vote up! Vote down!Points: 0You voted ‘up’Top Wed, 11/22/2017 - 22:41(Reply to #16)#174kingsFestus Thanks. :)

    I'll proof read the write-up again, i've been very busy that's the reason for the delay in the tutorial.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/30/2017 - 00:06(Reply to #17)#18FestusYou're good boss.

    I love your work.





    I am hoping I will one day become smart and learned enough to serve your likes and programming needs of the greater populace.Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 05:36(Reply to #18)#194kings...Vote up! Vote down!Points: 0You voted ‘up’Top Thu, 11/23/2017 - 17:03#204kingsLists

    List function in python is denoted as [].

    This square brackets contains all elements of the list, separated with comma(,).

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']



    That's an example of list assignment.



    To get length or Number of items in a list.



    >>> len(mylist)

    5

    I haven't discussed this, but len() function can also be used to get the length of a string too.



    List Indexing

    We can index position of elements of a list in python.

    Python's indexing start from 0.

    Therefore index 0 in the list created above is 'Lagos'

    Illustration:



    >>> mylist[0]

    'Lagos'

    >>> mylist[1]

    'Ogun'



    So we've seen how list are indexed.

    More to indeixng, we can also index a list from last position without counting the number of elements by using -1.

    Example:



    >>> mylist[-1]

    'Zamfara'

    Therefore:

    >>> mylist[-2]

    'AkwaIbom'



    List Slicing

    The concept behind list slicing is to cut out and return part of a list.

    Using [start:stop] method, where start is the value to index from and stop is the value to stop at.

    For example:



    >>> mylist = [ 'Lagos', 'Ogun', 'Rivers', 'AkwaIbom', 'Zamfara']

    >>> mylist[0:3]





    Notice that index 3 is 'AkwaIbom' but the return didn't include this.

    The concept behind that is that python start slicing your list from your first index and stop just before your last index. In this case our first and last index is 0 and 3 respectively.



    Also we can add an increment parameter to the list to increment how elements in the list are to be sliced

    So we use [start:stop:increment]



    >>> mylist[0:-1:2]



    So we can see the list is meant to start at index 0 and stop at the last index[-1] but we added an incre
  • mista_ceemista_cee Posts: 53
    edited October 2018
    Thanks man..... I'll try it right away 
Sign In or Register to comment.