raw_input and dict

I'm attempting to either put the value from "room" as the key, and "acquity" as the value a dictionary or each time the code runs have the end value "acquity" assigned to a new variable (it needs to run 32 times for 32 rooms). I cannot figure this out, sorry very new to this, any help would be greatly appreciated.

def main():

var=0

        while (var<33):

            room=raw_input("Input patient room Number ")




                ##Lists and prints/input for Procedural acuity
            print "1- No Procedures"
            print "2- IV Starts, Foley Catheter"
            print "3- Vitals, Neuro Check, Bladder Scans"
            print "4- Bedside Procedure, Physician post-op, frequent catheterization"
            a=raw_input("Input Procedural Acuity 1-4 ")

                ##Lists and prints/input for Nutritional acuity
            print "1- Setup Self"
            print "2- Ordering Assistance"
            print "3- Feed"
            print "4- Tubefeed, Aspiration Procedures"
            b=raw_input("Input Nutritional Acuity 1-4 ")

                ##Lists and prints/input for Medication acuity
            print "1- Minimal Oral"
            print "2- Moderate PO/IV"
            print "3- Dysphasia/Multi IV"
            print "4- Chemo/GTUBE/Complex IV"
            c=raw_input("Input Medication Acuity 1-4 ")

                ##Lists and prints/input for Mobility acuity
            print "1- Ad lib"
            print "2- Assist of SB"
            print "3- Assist of 1"
            print "4- Assist of 2"
            d=raw_input("Input Mobility Acuity 1-4 ")

                ##Lists and prints/inputs for Behavioral Acuity
            print "1- Calls Appropriately/No Needs"
            print "2- Some Education/ Calls Often"
            print "3- Anxious/ Calls Frequently"
            print "4- New Diagnosis, Calls very frequently, highly anxious"
            e=raw_input("Input Behavioral Acuity 1-4 ")

            a=float(a)
            b=float(b)
            c=float(c)
            d=float(d)
            e=float(e)

            Acuity1= a+b+c+d+e
            print "Patient in room %s, is graded at acuity %s"%(room, Acuity1)
            var= var + 1


if __name__ == '__main__':
    main()

Answers


At the start of your main(), let's change the name to get_roomnumbers_dict add:

def get_roomnumbers_dict():
    var=0    
    d = {} # this line to initalize the dictionary

    while (var<33):
        .....

At the end of your function:

        .....
        Acuity1= a+b+c+d+e
        print "Patient in room %s, is graded at acuity %s"%(room, Acuity1)
        d[int(room)] = Acuity1 # saves to the dictionary
        var= var + 1
        # end of while loop here

    return d # returns dictionary for someone to check acuity and room number

So then in your code you can simply have:

acquity_by_roomnumber = get_roomnumbers_dict() # and that gets the dictionary

Replace raw_input with input! I had the same error earlier! :P Also add import sys to the top!


Need Your Help

Recursive in angular link with watch

javascript angularjs

currently i'm doing that to make angular wait before run the scripts:

Why is it impossible to override a getter-only property and add a setter?

c# .net design properties getter-setter

Why do you think (or, why is it good that) Microsoft chose not to allow:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.