Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,150,630 members, 7,809,348 topics. Date: Friday, 26 April 2024 at 08:09 AM |
Nairaland Forum / Science/Technology / Programming / Python: I Have A Dictionary Problem ;) :-[ (1494 Views)
How Can I Create An Offline Dictionary App For Android / Add A Dictionary To A Grid / English Dictionary In Xml/json Format (2) (3) (4)
Python: I Have A Dictionary Problem ;) :-[ by dozies1: 7:34am On Sep 19, 2015 |
Found this code to solve transportation problem using Vogel's approximation. My goal is to modify it to accept input from a user but, my understanding of dictionary in python is quite weak. Hence any suggestion would be appreciated. from collections import defaultdict [url]http://rosettacode.org/wiki/Vogel's_approximation_method#Python[/url] |
Re: Python: I Have A Dictionary Problem ;) :-[ by Eminya(f): 7:38am On Sep 19, 2015 |
Didn't understand a thing, walks out of thread confused 1 Like |
Re: Python: I Have A Dictionary Problem ;) :-[ by dozies1: 7:55am On Sep 19, 2015 |
http://rosettacode.org/wiki/Vogel's_approximation_method#Python |
Re: Python: I Have A Dictionary Problem ;) :-[ by dozies1: 7:56am On Sep 19, 2015 |
Eminya:What's so confusing? |
Re: Python: I Have A Dictionary Problem ;) :-[ by prowlerovervoid: 8:32am On Sep 19, 2015 |
Eminya:same same. |
Re: Python: I Have A Dictionary Problem ;) :-[ by lordZOUGA(m): 8:35am On Sep 19, 2015 |
dozies1, what is your point? do you go about posting un-commented source codes with non-existent titles? What does the code do and whwt problem do you have with it? |
Re: Python: I Have A Dictionary Problem ;) :-[ by dozies1: 8:40am On Sep 19, 2015 |
Sorry about that. I mistakenly deleted my question while modifying my post lordZOUGA: |
Re: Python: I Have A Dictionary Problem ;) :-[ by dozies1: 8:49am On Sep 19, 2015 |
sorry about that prowlerovervoid: |
Re: Python: I Have A Dictionary Problem ;) :-[ by dozies1: 8:58am On Sep 19, 2015 |
basically i want turn the keys and values of this: to user inputcosts = {'W': {'A': 16, 'B': 16, 'C': 13, 'D': 22, 'E': 17}, |
Re: Python: I Have A Dictionary Problem ;) :-[ by prowlerovervoid: 9:51am On Sep 19, 2015 |
dozies1:user input? how? to what function? |
Re: Python: I Have A Dictionary Problem ;) :-[ by KelvinMega(m): 10:12am On Sep 19, 2015 |
use the raw_input function and assign it to a variable then use the variable as the key to your dictionary as in MyKey = raw_input('enter your key') MyDict = {MyKeywhatever you want here)} you should give a good description of what you're trying to achieve if you don't mind. there should be a better way out rather than this |
Re: Python: I Have A Dictionary Problem ;) :-[ by lordZOUGA(m): 10:19am On Sep 19, 2015 |
dozies1: Does the user already know the value of the keys? for example does the user already know that 'W' matches this: {'A': 16, 'B': 16, 'C': 13, 'D': 22, 'E': 17}? if not you probably should show them the table once they start the program. if they do, you just have to accept whatever input they provide verify it and match it to the table and then compute. for example:
|
Re: Python: I Have A Dictionary Problem ;) :-[ by dozies1: 10:41am On Sep 19, 2015 |
Thanks for your contribution KelvinMega:I'm trying to write a program that solves transportation problem this way
http://orms.pef.czu.cz/text/VogelAproxim.html |
Re: Python: I Have A Dictionary Problem ;) :-[ by dozies1: 11:06am On Sep 19, 2015 |
lordZOUGA:Thanks. The user wouldn't know. I would try your suggestion. |
(1) (Reply)
Job Opportunity / Please Web Programmers Help Me On This / Application In Php
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 26 |