Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python Weather

Name: Anonymous 2010-09-08 19:18

Weather prediction in Python 2.7

import random

filename = "weather.txt"
days = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]
weather = ["Cloudy", "Raining", "Clear", "Snowing"]

def pred(value):
    cl = "It's going to be either Cloudy or Clear tomorrow"
    cloudy = "It's going to be Cloudy tomorrow"
    clear = "It's going to be Clear tomorrow"
    if cur_day in text:
        if "clear" in text:
            print cloudy
        elif "raining" in text:
            print cl
        elif "snowing" in text:
            print cl
        elif "cloudy" in text:
            print clear
    else:
        print random.choice(weather)

while 1 > 0:
    cur_day = raw_input('Enter the current day: ')
    cur_weath = raw_input('Raining/Snowing/Clear/Cloudy ')
    day_weath = cur_day.lower() + " " + cur_weath.lower()
    if cur_day in days:
        break
    else:
        pass

old = open(filename, "r")
text = old.read() 
FILE = open(filename,"w")
FILE.writelines(day_weath)
FILE.close()

pred(0)

Name: Anonymous 2010-09-09 11:01

>>12
No it isn't; you're already in a loop and that is the only condition for stopping the loop. Make it the loop's condition, not some retarded 1 > 0.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List