##### Problem using input in Dictionary.. Help
 Problem using input in Dictionary.. Help roseojha Unladen Swallow Posts: 3 Threads: 3 Joined: Aug 2019 Reputation: Aug-25-2019, 08:15 AM Hey.. I am trying to calculate protein weight using dictionary where weight is given for each amino acid As and input I am giving = AALI which should give 440 weight But I am getting an error that the dictionary is not callable What I am doing wrong?? prot_seq = input('please write the amino acid sequence = ') prot_weight = {'A':89, 'V':117, 'L':131, 'I':131, 'P':115, 'F':165, 'W':204, 'M':149, 'G':75, 'S':105, 'C':121, 'T':119, 'Y':181, 'N':132, 'Q':146, 'D':133, 'E':147, 'K':146, 'R':174, 'H':155} for aa in prot_seq: weight=sum(prot_weight[aa]) print(weight) Reply ThomasL Minister of Silly Walks Posts: 360 Threads: 5 Joined: Jun 2019 Reputation: Aug-25-2019, 08:51 AM You are overwriting weight for each aa in the input and calculating the sum of an int so either: ```prot_weight = {'A':89, 'V':117, 'L':131, 'I':131, 'P':115, 'F':165, 'W':204, 'M':149, 'G':75, 'S':105, 'C':121, 'T':119, 'Y':181, 'N':132, 'Q':146, 'D':133, 'E':147, 'K':146, 'R':174, 'H':155} prot_sequence = input('please write the amino acid sequence = ') weight = 0 for aa in prot_sequence: weight += prot_weight[aa] print(weight)```or do it the pythonic way: ```prot_weight = {'A':89, 'V':117, 'L':131, 'I':131, 'P':115, 'F':165, 'W':204, 'M':149, 'G':75, 'S':105, 'C':121, 'T':119, 'Y':181, 'N':132, 'Q':146, 'D':133, 'E':147, 'K':146, 'R':174, 'H':155} prot_sequence = input('please write the amino acid sequence = ') weight = sum(prot_weight[character] for character in prot_sequence) print(weight)``` Reply

 Possibly Related Threads… Thread Author Replies Views Last Post Problem restricting user input in my rock paper scissors game ashergreen 6 889 Mar-25-2021, 03:54 AM Last Post: deanhystad single input infinite output problem Chase91 2 559 Sep-23-2020, 10:01 PM Last Post: Chase91 How do you replace a dictionary key with a new input? thewetmosquito 4 701 Aug-23-2020, 03:48 AM Last Post: perfringo Problem with the input marios 4 727 May-03-2020, 01:01 PM Last Post: marios User input & Dictionary tfernandes 5 1,487 Apr-03-2020, 07:12 PM Last Post: tfernandes problem coverting string data file to dictionary AKNL 22 2,218 Mar-10-2020, 01:27 PM Last Post: AKNL Get a value from a dictionary through input Anony 3 825 Jan-26-2020, 06:18 PM Last Post: buran Problem adding keys/values to dictionary where keynames = "property" and "value" jasonashaw 1 769 Dec-17-2019, 08:00 PM Last Post: jasonashaw problem in dictionary .get() roseojha 5 1,011 Aug-26-2019, 09:42 AM Last Post: perfringo simple string & input problem kungshamji 5 1,272 Jun-23-2019, 03:54 PM Last Post: kungshamji

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020