Loop With Python Tuple

Loop With Python Tuple

?Using loop with Tuple, we can iterate one by one items of a tuple.

?We can check all the items one by one to get required items in different ways.


Example

?Finding specific student name in a student that stored in tuple.

?Getting EVEN number from tuple which contain numbers.

?Getting ODD number from tuple which contain numbers.

?Analyzing different items from a tuple.

?Perform different operations to a specific item in a tuple.


Example

language? = ('Python', 'C++', 'JavaScript', 'C', 'Java', 'HTML‘)


for i in language:

? print(i)


Why need to use Loop with Tuple

?Using loop, we can analyze all the items or elements of a tuple

?Using loop, we can display all the items to screen

?Using loop, we can find any specific items or element from a tuple

?A lots of problem can be solve using loop with tuple


Changing element while using loop with tuple

language? = (3, 5, 1, 51, 6, 7, 8, 12)


Displaying Element:

for i in language:

? print(i)


Changing Element

for i in language:

? if i == 3? :

? ???? language[i] = 4 # you will get an error






要查看或添加评论,请登录

Rushikesh J.的更多文章

  • Linux Operating System

    Linux Operating System

    Linux Operating System ======================= => Linux is a community based OS => Linux is free & Open Source => Linux…

  • Infrastructure

    Infrastructure

    ================= Infrastructure ================= Servers (Machines) Databases Storage Network Security Backup =>…

  • Application Architectural Patterns

    Application Architectural Patterns

    =================================== 1) Monolithic Architecture (Outdated) 2) Microservices Architecture (Trending)…

  • DevOps Introduction

    DevOps Introduction

    =============== What is DevOps =============== DevOps = Development + Operations => DevOps is a culture/process in IT…

    2 条评论
  • Try and Exception in Python

    Try and Exception in Python

    Exception is the error and is an event, which occur when program statements are executing. It disrupts the flow of…

  • Python Array With Examples

    Python Array With Examples

    Array in Python Array in Python Array is the collection of items having same data type with contiguous memory location.…

  • Python Date Object

    Python Date Object

    We can work with time and date with Python. There are two module in Python time and datetime that used to work with…

  • String Formatting WITH Problems and Solution

    String Formatting WITH Problems and Solution

    What is String Formatting? It is the way to insert custom string or variable in a text (string). Using string…

  • SET Different Methods With Examples

    SET Different Methods With Examples

    SET Method : add() Working: This method is used to add element to set. Syntax: set.

  • Python SET Comprehension With Examples

    Python SET Comprehension With Examples

    What is Comprehension? ?We create a sequence from a given sequence is called comprehension. ?Sequence means list…

社区洞察

其他会员也浏览了