12 Discussion / Question Topics

Remove Filter
Member Avatar for
Member Avatar for pwolf

it says the following: Write a function that converts the time to 24hr format. Examples [CODE] >>> time24hr('12:34am') '0034hr' >>> time24hr('12:15pm') '1215hr' [/CODE] so i wrote the following: [CODE] def time24hr(tstr): a = tstr.split(':') am = {'12':'00','1':'01','2':'02','3':'03','4':'04','5':'05','6':'06', '7':'07','8':'08','9':'09','10':'10','11':'11'} pm = {'12':'12','1':'13','2':'14','3':'15','4':'16','5':'17','6':'18', '7':'19','8':'20','9':'21','10':'22','11':'23'} if 'am' in tstr: return am[a[0]] + a[1][:2] …

Member Avatar for Abhinav_4
0
3K
Member Avatar for lionaneesh

**Introduction** Hi guyz today I am going to writing a tutorial on dictionaries in Python....As per as getting comments from my readers I'll try to make this tutorial short.... **Layout** 1.What are dictionaries? 2.Why dictionaries? 3.How to declare/make dictionaries in Python? 4.What all you can do with a dictionary? 5.Interesting …

Member Avatar for vegaseat
0
655
Member Avatar for aprilcrash

Hi. I´m writing my first python program - a text adventure game. I want to have a list of possible things a dog could eat, what´s bad about them, how bad they are. So, I thought I´d do this: badfoods = [] keys = ['Food','Problem','Imminent death'] food1 = ['alcohol', 'alcohol …

Member Avatar for TrustyTony
0
286
Member Avatar for inuasha

How would I find the amount of characters in a string and then use that to print a certain amount of some character that you choose. For example: [CODE=Python] a = 'string' # this holds 6 characters print '*' * # amount of characters in string [/CODE]

Member Avatar for inuasha
0
241
Member Avatar for RLS0812

While correcting errors in someone else's code, I decided to completely rewrite the original script, and improve upon it. This is the basic code for making 3D arrays using dictionaries. [code] ar = { (x,y,z):0 # creating the array for x in range(3) for y in range (3) for z …

Member Avatar for vegaseat
0
262
Member Avatar for lionaneesh

[B][I][I][U]Introduction:-[/U][/I][/I][/B] [COLOR="Red"] Hi guyz today I am going to writing a tutorial on dictionaries in Python....As per as getting comments from my readers I'll try to make this tutorial Short....[/COLOR] [B][I][U] Layout:-[/U][/I][/B] [COLOR="Green"] 1.What are dictionaries? 2.Why dictionaries? 3.How to declare/make dictionaries in Python? 4.What all you can do with …

Member Avatar for colstonewall
0
398
Member Avatar for JoshuaBurleson

I'm working on learning GUI development, I'm attempting to utilize the GUI for a user to search the dictionary: my code so far is[CODE]from tkinter import * class Interface(Frame): def __init__(self, master): super(Interface, self).__init__(master) self.grid() self.create_widget() def create_widget(self): self.pwrd= Label(self, text='Address Book') self.pwrd.grid(row=0, column=2) self.searchlbl= Label(self, text='Enter Search Query:') self.searchlbl.grid(row=2, …

Member Avatar for JoshuaBurleson
0
282
Member Avatar for JoshuaBurleson

So I've finally fixed up the functionality of an address book I've been writing (not on to utilizing a GUI yet of course though.)However to save or reclaim the data from the last use of the address book I, obviously, need to write and reclaim it from a .txt file, …

Member Avatar for JoshuaBurleson
0
236
Member Avatar for banannamoofin

I am currently having problems displaying a file correctly once i have written a dictionary to the file. For this program the input file needs to have the format: ID: Date: Dayskept: ProductName e.g. 1:12/12/2011:12:A This is fine the first time I read the example file into a dictionary, but …

Member Avatar for TrustyTony
0
194
Member Avatar for Geemon

Hi I am new to the forums, and somewhat new to python. I'm trying to make a Text Based Adventure game. I don't have an error, but a bug. This is the code: [code]import descriptions inventory = [] gold = 0 acts = {"north":"hi"} def start(acts): print(descriptions.start) rm_a(acts) def rm_a(acts): …

Member Avatar for griswolf
0
205
Member Avatar for sc2player

Hi I was wondering how to extract info from a data file, and place it in a dictionary. Say you're given a file, in the following format: [CODE]tomCruise # Username Tom Cruise # Name Los Angeles, CA # Location http://www.tomcruise.com # URL Official TomCruise.com crew tweets. We love you guys! …

0
108
Member Avatar for sebcbien

Hello, I'm trying to update a dictionary using variable in a class. Something looking like this : [code=python] class testClass(object): def __init__(self): self.data0 = 0 self.data1 = 1 self.data2 = 2 self.data3 = 3 self.d = dict( data0 = self.data0, data1 = self.data1, data2 = self.data2, data3 = self.data3 ) …

Member Avatar for snippsat
0
170

The End.