New to Python - tiny coding assistance on user input function and assign to variable - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: New to Python - tiny coding assistance on user input function and assign to variable (/thread-16993.html) |
New to Python - tiny coding assistance on user input function and assign to variable - Mountain_Duck - Mar-23-2019 Hi all, I am new to Python and was wondering if anyone can simply help me with the following. I am tasked with created a basic drink ordering program and am stuck on the following: Getting size: Create a function called "get_size" that asks the user what size beverage the user wants (S,M,L) and assigns it to a variable called "size_input". If the user enters an invalid value, , assume the size is a Small. Based on their input, return a variable called “size” from the function. I am stuck on the second and third part - how do I create a variable from the users input? is it simply size_input = get_size? Furthermore, how do I create a "size" variable from an existing variable? It seems redundant. Apologies in advance if I am not wording/asking this correctly, this is a whole new world for me. THanks! MD RE: New to Python - tiny coding assistance on user input function - Yoriz - Mar-23-2019 size_input would be the result of user input size_input = input('what size beverage (S,M,L)')you are required to then check that the value of size_input is one of (S,M,L), if it is simply just size = size_inputotherwise size = 'S'and then return size |