It is a method in python set that add items from other iterables such as set, list, string etc to the parent set, thus updating the current set. add() method cannot take multiple iterables but update() can. It doesn’t return any value. And it modifies the given set.
Syntax:
set.update(iterables)
Example 1:
# Python code to understand update() method in set
# www.codewindow.in
s = {"amazing", "code"}
s1 = {"window", "hustle"}
s.update(s1)
print(s)
Output:
{'window', 'code', 'hustle', 'amazing'}
Explanation:
Here all the iterables in the set s1 are updated to the parent set (s).
Example 2:
# Python code to understand update() method in set
# www.codewindow.in
s = {5, 8, 4}
s1 = "code"
s.update(s1)
print(s)
Output:
{4, 5, 'c', 8, 'd', 'e', 'o'}
Explanation:
Here all the iterables in the string s1 are updated to the parent set (s).
Example 3:
# Python code to understand update() method in set
# www.codewindow.in
s = {5, 8, 4}
s1 = {"code":1, "search":2}
s.update(s1)
print(s)
Output:
{4, 5, 'code', 8, 'search'}
Explanation:
Here all the keys of the dictionary are updated to the parent set.
Note: if a dictionary is used as an iterable, the keys gets updated to the set, not the values.
Example 4:
# Python code to understand update() method in set
# www.codewindow.in
s = {"amazing", "code"}
s1 = {"window", "hustle"}
s2 = {"best"}
s.update(s1,s2)
print(s)
Output:
{'window', 'amazing', 'best', 'code', 'hustle'}
Explanation:
Here all the iterables in the set s1 and s2 are updated to the parent set (s). Thus it can take multiple iterables.
You missed
- Unlocking Innovation and Diversity: Accenture HackDiva Empowers Women in Tech with Cutting-Edge Solutions – codewindow.in
- QA Engineer Opportunities at Siemens Company: Apply Now – codewindow.in
- QA Engineer Opportunities at Siemens Company: Apply Now – codewindow.in
- Software Engineer Positions at Siemens Company: Apply Now – codewindow.in
- Cloud Engineer II Opportunities at Insight Company: Apply Now – codewindow.in
- Shape Your Career: Assistant Engineer Opportunities at Jindal Company – codewindow.in
- Shape Your Future: Executive Opportunities at Jindal Company – cdewindow.in
- Associate Engineer, Software Development at Ingram: Apply Now – codewindow.in
- Jade Company’s UI/UX Development Engineer Opportunities – Apply Now – codewindow.in
- Transform Your Career with S&P Global: Apply for the Software Development Engineer Role and Lead the Future of Financial Technology Innovation – codewindow.in
- Unlock Your Potential at Accenture as an Associate Software Engineer – Elevate Your Career with Innovation and Excellence – codewindow.in
- Accelerate Your Career: Join NVIDIA’s Elite Software Engineering Internship Program and Shape the Future of Technology – codewindow.in
- C Programming Interview Questions – codewindow.in
- Lead the Way in Analytics: Specialist Position at Razorpay – codewindow.in
- Innovate with Cyient: Junior Software Engineer Wanted – codewindow.in
- Innovate with Volvo: Associate Software Engineer Wanted – codewindow.in
- Lead the Tech Revolution: Full Stack Developer at Unisys – codewindow.in
- Software Engineer at ABB: Unlock Innovation and Shape the Future – codewindow.in
- IBM Associate Systems Engineer Job: Boost Your Career with a Leading Technology Giant – codewindow.in
- Make Your Mark in Android Development: Join Concentrix – codewindow.in
- Infosys is Growing: Field Services Developer Role Now Open – codewindow.in
- Start Your IT Career Journey with Amazon: IT Services Support Associate I Opportunity – codewindow.in
- Shape the Future of Web: Front-End Software Engineer Opportunity at Google Cloud – codewindow.in
- Barclays QA Team Expands: QA Analyst Role Now Open- codewindow.in
- Eurofins QA Team Grows: Test Engineer Role Now Open – codewindow.in
- Exciting Opportunity: Java Spring Boot Senior Developer Role at Infosys – codewindow.in
- Unlock Your Potential at Nokia: Software Engineer Opportunities Await – codewindow.in
- Join Microsoft’s World-Class Team as a Software Engineer and Shape the Future of Technology – codewindow.in
- Virtusa is Seeking Talented React JS Developers to Drive Digital Excellence – codewindow.in
- Join IBM Dynamic Team as a Full Stack Developer and Shape the Future – codewindow.in
- EY Welcomes Aspiring AI/ML Interns to Unlock the Future of -codewindow.in
- Exciting Opportunity: Project Engineer at Rockwell Automation- codewindow.in
Also Checkout
- Adobe
- Advanced Coading
- Advanced course
- Ajax
- Algorithm
- Amagi
- Amazon Interview Questions
- Angular JS
- Aptitude
- Aptitude tricks
- Automata Fixing
- Basic Coding
- big data
- Books
- Bridge2i
- C programming
- Campgemini Interview Questions
- Capgemini Coding Questions
- Capgemini Pseudocode
- Celebal Tech
- Cloud Computing
- code nation
- Coding Questions
- Cognizant Placement
- commvault Systems
- Computer Network
- CSS
- CTS
- Data Science
- Data Structure
- Data Structure and Algorithm
- DBMS
- De Show Interview Questions
- deloitte
- Deutsche Bank Interview questions
- Enhance Communication
- Epam Full Question Paper
- Extempore
- Exxon Mobil interview questions
- filpkart
- Fractal Analytics Interview Questions
- Genpact
- Grab
- GreyB Interview Questions
- Group Discussion
- Guidance for Accenture
- Gupshup
- Hackathon 2024
- HCL Interview Questions
- Hexaware
- HFCL
- HR Questions
- HTML5
- IBM Interview questions
- IBM Questions
- Incture Interview Questions
- Infineon Technologies Interview Questions
- Infosys
- Infosys Interview Questions
- Internship
- Interview Experience
- Interview Questions
- ITC Infotech
- itron
- JavaScript
- JECA
- Job Info
- JQuery
- Kantar Interview Questions
- Language Confusion
- language confussion
- Larsen & Turbo
- Latenview AnalyticsInterview questions
- Lexmark International Interview Questions
- Machine Learning
- Media.net
- Mindtree Interview Questions
- Miscellaneous
- Mock Test Series
- MongoDB
- Morgan Stanly Interview Questions
- nagarro
- navi
- NodeJS
- NTT Data Interview Questions
- NVDIA
- NVDIA interview questions
- Operating System
- Optum
- PayU
- Persistent INterview Questions
- PHP and MYSQL
- Previous Coding Questions
- Programming in C
- Programming in C++
- Programming in JAVA
- Programming in Python
- Pseudo Code
- pseudocode
- PWC Interview Questions
- Python
- Quiz
- Razorpay
- ReactJS
- Recruiting Companies
- Revature
- salesforce
- Samsung
- Schlumberger
- Seimens
- Slice
- Smart Cube
- Software Engineering
- Study Material
- Tally Solutions
- tata cliq
- TCS
- TCS NQT
- TCS NQT Coding Questions
- Tech Mahindra Coding Questions
- Tech Mahindra Questions
- Technical Preparation
- Teg Analytics
- Tejas Network Interview Questions
- Texas Instrument Interview Questions
- Tiger Analytics
- Uncategorized
- UnDosTres
- Unstop
- Verbal Ability
- Verbal Lesson
- Web Development
- wipro
- Wipro Coding Questions
- Wipro interview Questions
- Wipro NLTH
- WIpro NLTH Coding Solve
- Zenser
- Zoho Interview Questions