<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kumatso1</title>
    <description>The latest articles on DEV Community by Kumatso1 (@kumatso1).</description>
    <link>https://dev.to/kumatso1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1433712%2Faf8eb110-ae3d-4dc9-b264-aa79e4546c5e.jpeg</url>
      <title>DEV Community: Kumatso1</title>
      <link>https://dev.to/kumatso1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/kumatso1"/>
    <language>en</language>
    <item>
      <title>Sorting and Searching in Python(looking for help)</title>
      <dc:creator>Kumatso1</dc:creator>
      <pubDate>Mon, 13 May 2024 02:18:48 +0000</pubDate>
      <link>https://dev.to/kumatso1/sorting-and-searching-in-pythonlooking-for-help-38lf</link>
      <guid>https://dev.to/kumatso1/sorting-and-searching-in-pythonlooking-for-help-38lf</guid>
      <description>&lt;p&gt;I wrote this Python code but it is giving me this error shown in the screenshot and I don't know where it is coming from. I am a beginner in Python.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fay2wj78xfsvgdivkxg12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fay2wj78xfsvgdivkxg12.png" alt="Image description" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Program:&lt;br&gt;
""" &lt;br&gt;
    This program defines the Album class with the specified attributes and string representation.&lt;br&gt;
    Then, it creates two lists albums1 and albums2, populates them with Album objects,&lt;br&gt;
    and performs various operations like sorting, swapping, copying, adding elements, and searching.&lt;br&gt;
"""&lt;br&gt;
class Album:    # defineing Album class&lt;br&gt;
    def &lt;strong&gt;init&lt;/strong&gt;(self, album_name, number_of_songs, album_artist):&lt;br&gt;
        self.album_name = album_name&lt;br&gt;
        self.number_of_songs = number_of_songs&lt;br&gt;
        self.album_artist = album_artist&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def __str__(self):  
   return f"({self.album_name}, {self.album_artist}, {self.number_of_songs})"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;def main():&lt;br&gt;
    albums1 = []&lt;br&gt;
    albums1.append(Album("Thriller", 9, "Michael Jackson"))&lt;br&gt;
    albums1.append(Album("Back in Black", 10, "AC/DC"))&lt;br&gt;
    albums1.append(Album("The Dark Side of the Moon", 10, "Pink Floyd"))&lt;br&gt;
    albums1.append(Album("Rumours", 11, "Fleetwood Mac"))&lt;br&gt;
    albums1.append(Album("Born to Run", 8, "Bruce Springsteen"))&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Print albums before sorting
print("Albums before sorting:")
for album in albums1:
    print(album)

# Swap elements at positions 1 and 2
albums1[1], albums1[2] = albums1[2], albums1[1]

# Print albums after swapping
print("\nAlbums after swapping positions 1 and 2:")
for album in albums1:
    print(album)

albums2 = []
albums2.append(Album("Purple Rain", 9, "Prince"))        
albums2.append(Album("Like a Prayer", 9, "Madonna"))
albums2.append(Album("Bridge Over Troubled Water", 11, "Simon &amp;amp; Garfunkel"))
albums2.append(Album("Achtung Baby", 11, "U2"))
albums2.append(Album("Nevermind", 14, "Nirvana"))

# Print albums2
print("\nAlbums2:")
for album in albums2:
    print(album)
# Copy all albums from albums1 to albums2
albums2.extend(albums1)

# Add additional albums
albums2.append(Album("Dark Side of the Moon", 9, "Pink Floyd"))
albums2.append(Album("Oops!... I Did It Again", 16, "Britney Spears"))

# Print albums2 after additions
print("\nAlbums2 after additions:")
for album in albums2:
    print(album)

# Sort albums2 alphabetically by album name
albums2.sort(key=lambda album: album.album_name)

# Print albums2 after sorting alphabetically
print("\nAlbums2 after sorting alphabetically:")
for album in albums2:
    print(album)

# Search for Dark Side of the Moon
dark_side_index = albums2.index(Album("Dark Side of the Moon", 9, "Pink Floyd"))
(f"\nIndex of Dark Side of the Moon: {dark_side_index}")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == "&lt;strong&gt;main&lt;/strong&gt;":&lt;br&gt;
    main()&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
