Skip to content

Instantly share code, notes, and snippets.

with open('your_file.txt', 'r') as file:
paragraphs = file.read().split('$')
# Remove leading and trailing whitespace from each paragraph
paragraphs = [p.strip() for p in paragraphs]
# Remove duplicates while preserving order
unique_paragraphs = []
seen = set()
import random
def jeu_de_devinette():
nombre_a_deviner = random.randint(1, 20)
essais = 0
print("Bienvenue dans le jeu de devinette !")
print("Je pense à un nombre entre 1 et 20.")
while True:
@hdary85
hdary85 / 2.py
Last active November 9, 2023 04:21
import win32com.client
import pandas as pd
import io
from datetime import datetime
# Connect to Outlook
outlook = win32com.client.Dispatch("Outlook.Application")
namespace = outlook.GetNamespace("MAPI")
# Recherche du dossier principal par son nom
%let folder_path = "your_folder_path"; /* Specify the path to your folder */
%let table_name = "xyz"; /* Specify the table name to search for */
/* Create a fileref for the directory */
filename dirlist "&folder_path" ;
/* Get a list of SAS program files in the folder */
data sas_files;
length file_name $256.;
infile dirlist truncover;
import xlrd
# Open the workbook
workbook = xlrd.open_workbook('your_excel_file.xls')
# Select the first sheet
sheet = workbook.sheet_by_index(0)
# Iterate through rows and columns to read data
for row in range(sheet.nrows):
def populate_tree(tree, item, dictionary):
if isinstance(dictionary, dict):
for key, value in dictionary.items():
if isinstance(value, dict):
sub_item = tree.insert(item, "end", text=key)
populate_tree(tree, sub_item, value)
else:
tree.insert(item, "end", text=key, values=(value,))
else:
tree.insert(item, "end", values=(dictionary,))
# Function to find interdependent product groups
def find_interdependent_groups(transactions):
product_groups = []
remaining_products = set()
# Get unique products
for products in transactions:
remaining_products |= products
transactions_copy = transactions.copy() # Create a copy of the list
# -*- coding: utf-8 -*-
"""
Created on Wed Nov 29 15:02:06 2023
@author: Lenovo
"""
nested_dict = {
'rule1': {
'name': 'xy1z11111',
'Reccurence': {
import tkinter as tk
from tkinter import simpledialog, messagebox
class NestedDictManager:
def __init__(self, root):
self.root = root
self.root.title("Nested Dictionary Manager")
self.data = {
'key1': 'value1',
import tkinter as tk
from tkinter import simpledialog, messagebox
class NestedDictManager:
def __init__(self, root, data):
self.root = root
self.root.title("Nested Dictionary Manager")
self.data = data # Use the provided dictionary
self.tree = tk.ttk.Treeview(self.root)