Here’s an example of a basic FriendList type in Python, which can store a list of friends and provide some basic operations like adding a friend, removing a friend, and displaying the list:

class FriendList: def __init__(self): self.friends = [] def add_friend(self, friend_name): if friend_name not in self.friends: self.friends.append(friend_name) print(f"{friend_name} has been added to your friend list.") else: print(f"{friend_name} is already your friend.") def remove_friend(self, friend_name): if friend_name in self.friends: self.friends.remove(friend_name) print(f"{friend_name} has been removed from your friend list.") else: print(f"{friend_name} is not in your friend list.") def show_friends(self): if self.friends: print("Your friends:") for friend in self.friends: print(friend) else: print("You have no friends yet.")

Example Usage:

# Create a new friend list my_friends = FriendList() # Add friends my_friends.add_friend("Alice") my_friends.add_friend("Bob") # Show friends my_friends.show_friends() # Remove a friend my_friends.remove_friend("Alice") # Show updated list of friends my_friends.show_friends()

Output:

Alice has been added to your friend list. Bob has been added to your friend list. Your friends: Alice Bob Alice has been removed from your friend list. Your friends: Bob

This basic structure can be expanded with additional features such as checking if a friend exists, sorting the list, or handling friend requests.#Friend.tech前景预测 🥰😋😋😋😎😎