I am self teaching myself python and I have hit a question that I can't seem to figure out dealing with raw_input. This is the code that is confusing me: print "How tall are you?", height = raw_input() print "So, you're %r tall ." % (height) I input my height as 5' 10" and get the follwing output: How tall are you? 5' 10" So, you're '5' 10"' tall . What am I missing from my code to fix the output so it reads properly?

Member Avatar
Member Avatar
+1 forum 4

I'm creating a program that carrys out certain things dependent on the user input. One function is to read text from a text file, another is to add text to the same text file. I'm unsure about how to add an exception handler to make sure the text input is in the right format, The text file contains a list of people with their birthdays in the form Mike,Dec,25 John,Apr,13 and I don't know what I would put around my code to add text, in order to not crash the program when text isn't entered in this format. Any help …

Member Avatar
Member Avatar
+0 forum 1

Hi all ; [ICODE]ask=raw_input("type the query: ") [/ICODE] when i type [ICODE]23+9[/ICODE] after this; i wanna get '32' result.. like ; [ICODE]>>>type the query: 3+5 >>>result : 8[/ICODE] this is what i want.. thank you..

Member Avatar
Member Avatar
+0 forum 1

Hey, everybody, I'm a newbie at Python (2.7.1), and new to DaniWeb as well. and the apparent simplicity of Python got me interested in programming (seriously, the only thing before this was HTML). Anyway... I was taking a test and thought that after I was finished I could make an equation calculator. I've got a few simple equations slapped on there, for proof-of-concept, and they work fine. However, I would like to go back to the user input line of code. How do I go about doing this? I've Googled it, and there's no "goto" function like there is in …

Member Avatar
Member Avatar
+0 forum 30

Hey guys, I've been lurking around these forums for a few weeks now, and this website is by far the most helpful of any site I've visited as far as honing my newfound Python skills, and I figured it's time I jump in and ask some of the more specific questions that have been plaguing me. So here goes. I'm working on my first non-school-assigned program, just a simple unit converter, and I'm having some trouble with the raw_input() method. If I code it like the following code block, everything works fine: [code=python] def distanceConverter(dfrom, funit, dto, tunit): print dfrom …

Member Avatar
Member Avatar
+0 forum 6

Hi... Let's say that we have this: [CODE]somme = raw_input('1 + 1 = ') if somme == 2: print 'Good - Time For Answer: ' else: print 'False - The Right Answer is: 2 -Time For Answer:'[/CODE] So... how can we get the time for writing any things on raw_input()

Member Avatar
Member Avatar
+0 forum 3

Dear Community, hopefully someone can explain this to me in simple terms: I would like to store raw input from a User without waiting for him to press Enter. And would it be possible to still check if the response is one of the predefined options? My raw input consists of a single character - a number from 1 to 7. I run the program in a terminal window in Windows. I looked online and found that to solve this problem, it is necessary to use the msvcrt.getch() function but I don't understand (literally) how to apply this to my …

Member Avatar
Member Avatar
+0 forum 1

I am new to programming in Python and I am just wondering if I could have some help. I am trying to write a program which creates diary entries for events and I am currently trying to convert the raw_input from the user into a date (yyyy/mm/dd) and time (24hr hh:mm). I have tried looking around for a solution but nothing I do seems to work. I am also trying to append each event to file and display them on separate lines when they are loaded from the file. Here is my code up to now: [code] import cPickle def …

Member Avatar
Member Avatar
+0 forum 17

[code]#!C:\Python26\python.exe # Three-times-the-square-root-of-your-age.py # # This is a python program that # will input the user's name and age # the output will be 3 times the # square root of the user's name # # author: Min Ku "Peter" Joo # last revision: 02/10/2010 import os import math def main ( ): sayWelcome ( ) getUsersName ( ) getUsersAge ( ) calThreeSqrtOfAge ( ) tellUserOutcome ( ) programPause ( ) def sayWelcome ( ): # Welcomes the user to the program print "Welcome to Peter's program." def getUsersName ( ): # asks the user for his or her full …

Member Avatar
Member Avatar
+0 forum 2

Can someone please tell me what I am doing wrong. I know this is easy, but I haven't managed to make it work properly. [code=python] overwrite = None while overwrite != 'Y'.lower() or overwrite != 'N'.lower(): overwrite = raw_input("Do you want to overwrite (Y/N)? ") [/code] It doesn't exit the while loop. Thanks.

Member Avatar
Member Avatar
+0 forum 6

The End.