Menu

Different ways of writting loops in Python

Lets see we have a list of inetgers name x. 

x = [3,3,3,4,4,4,3,3,5,5,6,6,7,8,9,9,9]

Now iterate over this list using differnet loops.


  1. For loop

          #To read all  the elements from list

for elem in x:
    print(elem)


       #To read element from specific index using range(startindex, stopindex)

        for i in range(2, len(x)):

            print(x[i])

 

  1. While loop
    i = 4
while i < len(x):
    print(x[i])
    i+=1

    Prefix sling is not bound | AEM Dialog

    [ERROR] ValidationViolation: Could not parse FileVault Document View XML: The prefix "sling" for attribute "sling:resourceSuperType" associated with an element type "jcr:root" is not bound. @ jcr_root\apps\wknd\components\banner\.content.xml, line 6, column 42, validator: jackrabbit-docviewparser, JCR node path: /apps/wknd/components/banner, Throwable: The prefix "sling" for attribute "sling:resourceSuperType" associated with an element type "jcr:root" is not bound.


    Resolution:

    Sling is not added in the xml name space. In jcr:root element add the follwing xmlns. 

    xmlns:sling="http://sling.apache.org/jcr/sling/1.0"

    Difference Casings in Programming

    In this blog we will understand the differences between the most widely used case types while writing the variable name or function or method name in computer programming.

    1. Camel Case: In Camel case we start writing from small letter and then after write first character of every word in capital. e.g. javaVariableNaming, namingConvension, camelCaseType

    2. Pascal Case: Pascal case is similar to camel case the only difference is, we write first letter of first word also capital. e.g. VariableName = "Name", BackgroundColorCode = "red", MaximumMarks = 100

    3. Snake Case: In Snake case we write all characters either in lower or upper case and seprate the words with undescore character(_). This is widely use in JavaScript, Node JS, Python e.g. modal_id = "pop-singup", PETROL-MILEAGE-CAR = 20

    4. Kebab Case: Kebab case is similar to Snake case where we write eveything in small or capital case and seprate the word with hyphen(-) e.g. color-code = "#FFFFFF", max-value-allow = 55, DIESEL-MILEAGE-CAR = 20