Most People Don’t Know THIS About Tuples In Python

Hacking Truth
0

 

Most People Don’t Know THIS About Tuples In Python

 

 

when we create tuples in python usually we go ahead and create a tuple with parentheses we say (one two three ) and ofcourse this provides a tuple and we can even test that out by checking that this is a tuple and when we run the program. we're going to get back that this is a tuple.

 

 

Most People Don’t Know THIS About Tuples In Python

 

now one thing that a lot of people don't know is that the parentheses are not required for creating a tuple if we go ahead and print this again we're going to get the same class of tuple.

 

 

Most People Don’t Know THIS About Tuples In Python

 

 

now this also works if you only have one element as you can see we only have one and when we print it it's still going to be a tuple.

 

 

Most People Don’t Know THIS About Tuples In Python

 

 

And what's interesting about this is that if we create a parentheses and add a one inside it we're going to get an integer back because it does not recognize this as a tuple it recognizes this as an integer with parentheses and that helps us with the order of operations of course.

 

Most People Don’t Know THIS About Tuples In Python

 

 

But if we want to define a tuple with a number inside we need to provide the comma so that the program can understand that we're using a tuple.





Disclaimer

All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.
 
 

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)
Our website uses cookies to enhance your experience. Learn More
Accept !