Created
July 19, 2020 17:23
-
-
Save kshirsagarsiddharth/b6358f00cff8fe0ec5bc4f2ba27af7db to your computer and use it in GitHub Desktop.
using replace method on namedtuple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections import namedtuple | |
| animal = namedtuple('animal',['species_name','legs_no','color']) | |
| dog = animal('canine',4,'white') | |
| dog = dog._replace(legs_no = 6) | |
| print(dog.legs_no) | |
| # Output: 6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment