good displaying house information in house
H1=['Gur']
H2=['Cha']
H3=[]
H4=[]
H5=['Sur', 'Kuj']
H6=['Bhd', 'Shu', 'Ket']
H7=[]
H8=['Sha']
H9=['Lag']
H10=[]
H11=[]
H12=['Rah']
again
Adjusted Planet Signs:
H1=['Gur+']
H2=['Cha+']
H3=[]
H4=[]
H5=['Kuj+', 'Sur+']
H6=['Shu-', 'Ket+', 'Bhd-']
H7=[]
H8=['Sha-']
H9=['Lag']
H10=[]
H11=[]
H12=['Rah-']
----------
https://www.programiz.com/python-programming/online-compiler/
-------------------------------
# Reference dictionary for Nakshatra to House mapping
nakshatra_to_house = {
# Mesh (H12)
'Purvabhadra 4': 'H12', 'Uttarabhadra 1': 'H12', 'Uttarabhadra 2': 'H12',
'Uttarabhadra 3': 'H12', 'Uttarabhadra 4': 'H12', 'Revati 1': 'H12',
'Revati 2': 'H12', 'Revati 3': 'H12', 'Revati 4': 'H12',
# Vibh (H1)
'Ashwini 1': 'H1', 'Ashwini 2': 'H1', 'Ashwini 3': 'H1', 'Ashwini 4': 'H1',
'Bharani 1': 'H1', 'Bharani 2': 'H1', 'Bharani 3': 'H1', 'Bharani 4': 'H1',
'Krittika 1': 'H1',
# Mitu (H2)
'Krittika 2': 'H2', 'Krittika 3': 'H2', 'Krittika 4': 'H2',
'Rohini 1': 'H2', 'Rohini 2': 'H2', 'Rohini 3': 'H2', 'Rohini 4': 'H2',
'Mrigashira 1': 'H2', 'Mrigashira 2': 'H2',
# Kark (H3)
'Mrigashira 3': 'H3', 'Mrigashira 4': 'H3', 'Ardra 1': 'H3', 'Ardra 2': 'H3',
'Ardra 3': 'H3', 'Ardra 4': 'H3', 'Punarvasu 1': 'H3', 'Punarvasu 2': 'H3',
'Punarvasu 3': 'H3',
# Simh (H4)
'Punarvasu 4': 'H4', 'Pushyami 1': 'H4', 'Pushyami 2': 'H4', 'Pushyami 3': 'H4',
'Pushyami 4': 'H4', 'Ashlesha 1': 'H4', 'Ashlesha 2': 'H4', 'Ashlesha 3': 'H4',
'Ashlesha 4': 'H4',
# Kany (H5)
'Magha 1': 'H5', 'Magha 2': 'H5', 'Magha 3': 'H5', 'Magha 4': 'H5',
'Purvaphalguni 1': 'H5', 'Purvaphalguni 2': 'H5', 'Purvaphalguni 3': 'H5',
'Purvaphalguni 4': 'H5', 'Uttaraphalguni 1': 'H5',
# Tula (H6)
'Uttaraphalguni 2': 'H6', 'Uttaraphalguni 3': 'H6', 'Uttaraphalguni 4': 'H6',
'Hasta 1': 'H6', 'Hasta 2': 'H6', 'Hasta 3': 'H6', 'Hasta 4': 'H6',
'Chitra 1': 'H6', 'Chitra 2': 'H6',
# Vish (H7)
'Chitra 3': 'H7', 'Chitra 4': 'H7', 'Swati 1': 'H7', 'Swati 2': 'H7',
'Swati 3': 'H7', 'Swati 4': 'H7', 'Vishaka 1': 'H7', 'Vishaka 2': 'H7',
'Vishaka 3': 'H7',
# Dhan (H8)
'Vishaka 4': 'H8', 'Anuradha 1': 'H8', 'Anuradha 2': 'H8', 'Anuradha 3': 'H8',
'Anuradha 4': 'H8', 'Jyeshtha 1': 'H8', 'Jyeshtha 2': 'H8', 'Jyeshtha 3': 'H8',
'Jyeshtha 4': 'H8',
# Maka (H9)
'Mula 1': 'H9', 'Mula 2': 'H9', 'Mula 3': 'H9', 'Mula 4': 'H9',
'Purvashadha 1': 'H9', 'Purvashadha 2': 'H9', 'Purvashadha 3': 'H9',
'Purvashadha 4': 'H9', 'Uttarashadha 1': 'H9',
# Kumb (H10)
'Uttarashadha 2': 'H10', 'Uttarashadha 3': 'H10', 'Uttarashadha 4': 'H10',
'Shravana 1': 'H10', 'Shravana 2': 'H10', 'Shravana 3': 'H10', 'Shravana 4': 'H10',
'Dhanishta 1': 'H10', 'Dhanishta 2': 'H10',
# Meen (H11)
'Dhanishta 3': 'H11', 'Dhanishta 4': 'H11', 'Shatabhisha 1': 'H11',
'Shatabhisha 2': 'H11', 'Shatabhisha 3': 'H11', 'Shatabhisha 4': 'H11',
'Purvabhadra 1': 'H11', 'Purvabhadra 2': 'H11', 'Purvabhadra 3': 'H11'
}
# Planets mapping to abbreviations
planet_abbr = {
'Lagna': 'Lag', 'Surya': 'Sur', 'Chandra': 'Cha', 'Mangal': 'Kuj', 'Budha': 'Bhd',
'Guru': 'Gur', 'Shukra': 'Shu', 'Shani': 'Sha', 'Spashth Rahu': 'Rah', 'Spashth Ketu': 'Ket'
}
# Input data
planet_data = [
("Lagna", "050 Dhan 49 54", "Mula", 2),
("Surya", "260 Simh 41 21", "Purvaphalguni", 4), # U Phalguni--> Uttaraphalguni
("Chandra", "Vibh Dhan 52 34", "Krittika", 4), # P Ashadha -->Uttarashadha
("Mangal", "270 Simha 01 02", "Purvaphalguni", 2),
("Budha", "220 Kanya 23 03", "Hasta", 2), #P Phalguni -->Purvaphalguni
("Guru", "260 Kany 58 08", "Ashwini", 2),
("Shukra", "070 Tula 58 34", "Uttaraphalguni", 2),
("Shani", "130 Kark 15 13", "Jyeshtha", 2),
("Spashth Rahu", "190 Meen 53 00", "Uttarabhadra", 2),
("Spashth Ketu", "190 Kany 53 00", "Uttaraphalguni", 4)
]
# Initialize houses dictionary
houses = {f"H{i}": [] for i in range(1, 13)}
# Process the planet data
for planet, _, nakshatra, padam in planet_data:
key = f"{nakshatra} {padam}"
house = nakshatra_to_house.get(key, "")
if house:
houses[house].append(planet_abbr[planet])
# determine which is good and bad planet as janma lagna
# Output the result for each house
for house, planets in houses.items():
print(f'{house}={planets}')
print("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$")
# Find Lagna house position
lagna_house = None
for planet, _, nakshatra, padam in planet_data:
key = f"{nakshatra} {padam}"
house = nakshatra_to_house.get(key, "")
if house:
houses[house].append(planet_abbr[planet])
if planet == "Lagna":
lagna_house = house
# Output the result for each house before applying the + or - logic
print("Initial House Allocation:")
for house, planets in houses.items():
print(f'{house}={planets}')
# Define rules for appending + or - based on Lagna house
positive_houses = {'H12', 'H1', 'H4', 'H5', 'H8', 'H9'}
positive_planets = {'Sur', 'Cha', 'Kuj', 'Ket','Gur'}
negative_planets = {'Bud', 'Shu', 'Sha', 'Rah','Shu'}
# Apply sign logic based on Lagna house and eliminate duplicates
print("\nAdjusted Planet Signs:")
for house, planets in houses.items():
updated_planets = set() # Use a set to avoid duplicates
for planet in planets:
if planet == 'Lag': # Skip adding sign for Lagna
updated_planets.add(planet)
continue
if lagna_house in positive_houses: # Lagna in one of the positive houses
if planet in positive_planets:
updated_planets.add(f"{planet}+")
else:
updated_planets.add(f"{planet}-")
else: # Lagna in other houses
if planet in positive_planets:
updated_planets.add(f"{planet}-")
else:
updated_planets.add(f"{planet}+")
houses[house] = list(updated_planets) # Convert set back to list for display
# Display the updated house allocations
for house, planets in houses.items():
print(f'{house}={planets}')