[Tutor] Removing Unnecessary Indentation and other problems

Steve Willoughby steve at alchemy.com
Sat Nov 16 00:47:38 CET 2013


On your first question, make sure you have the right version of Tcl/Tk for your system (usually a tar.gz file is for Unix-like systems, although some programs like WinZip can read those files too).  You may be able to get help from a Tcl/Tk forum on specifics of building that.  However, doesn't your Python installation come with tkinter included?  Most do.

On your second question, the issue is that your program is inserting some kind of spaces or tabs when printing out that dictionary.  How are you printing it?  Include the actual code of your program please when asking questions about it so we know what's going on.  Generally, though, you will want to use a formatted print statement such as the % operator with print, or the .format() method with print.  It looks like you're printing a tab between the key and value, which is going to produce output like that if the keys don't fit within a single tab zone (8 characters usually).

HTH HAND
steve

 
On 15-Nov-2013, at 14:44, harvey trasmontero <harveytrasmontero at hotmail.com> wrote:

> Good day,
> 
> I have two problems. First one is, using and downloading tkinter. I have searched about it and it led me to a download page. But then, I didnt know which one to download so I chose the first one on the right. It led me to a zip file and its saying extract the'.tar.gz files for tcl and tk' but I couldn't find it in the zip file that I downloaded. What do I do?
> 
> Secondly, I am having a hard time finding an answer to my question, which is how to remove indentation on dictionary when I run my program. I've searched google and all but I couldnt find anything. So the dictionary kind of looks like this:
> Dic = {"Sunnynook Rd":'50',"Carlisle Rd":'50',"East Coast Rd":'50',"Upper Harbour Drive":'50',
>     "Lake Rd":'50',"Waipa St":'50',"Great North Rd":'50',"Richardson Rd":'50',"Atkinson Rd":'50'}
> 
>  My problem is when I run my program, there are unnecessary indentations in Upper Harbour Drive and Lake Rd. So when I run it it looks like this:
> Atkinson Rd            50
> Carlisle Rd              50
> Lake Rd          50
> Upper Harbour Drive            50
> Waipa St                 50
> Sunnynook Rd         50
> Richardson Rd        50
> Great North Rd       50
> East Coast Rd         50
> 
> How do I align Lake Rd and Upper Harbour Drive so it wont look silly like the one above?
> 
> Thank you and hope to hear from one of you tutors
> 
> Regards
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20131115/01394c64/attachment.html>


More information about the Tutor mailing list