I am new to this site, and new to programming. I am currently pursuing an associates in associates in programming and am taking an intro class to python, but i am having a serious issue with raw_input.

For some reason i am having a hard time understand raw_input and its intended use. I have no idea why im having such difficulties. I searched this site and could not find what i was looking for. I looked it up in the pythin glossary and that wasnt very helpful.

if someone could help me out. For example i am currently in the process of programming a stock trader program and im curious how i would use raw_input in relation to ticketers like pep for pepsi or f for ford in relation to an equation

i don't know if i explained that to well but i hope i can get some help.

5 Years
Discussion Span
Last Post by JoshuaBurleson

raw_input is used for user input on the command line, or in IDLE for example:

word=raw_input('Enter a word: ')
print word

it is important to note that raw_input does not work in python 3.x it was combined with input() after python 2.

If you're not sure which one you are using, if you try to use raw_input and get an error regarding the raw_input, you are probably using python 3. In which case the code above would look like this:

word=input('Enter a word: ')

Also, post code to show effort in. Effort in effort out, more specifically as Pytony would say http://www.daniweb.com/software-development/python/threads/359823

Edited by JoshuaBurleson: n/a


but what is its purpose in relation to variable equations?

to reference my stock trader example if a user wanted to buy 20 pepsi stocks could i do


i know this wouldnt work but that is what im trying to understand is raw_input vs input in terms of equations.


It seems to me that raw_input was more for strings whereas input was for numeralsokay, so for python 2.7, which apparently is what you're using you could do "assuming the user knows the ticker code:

stockname=raw_input('What stock would you like to purchase?: ')
'''we are going to pretend you have a dictionary of prices for the ticker names'''
if stockname in prices.keys():
amount=input('How many shares would you like?: ')
'''I used float() because we are talking about stocks which often can be like 58.29, which is a floating point number'''
print('Your total is $',total_price)

Edited by JoshuaBurleson: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.