[Tutor] List of tuples

2016-04-19 Thread isaac tetteh
I have a list like this 
[
("name",2344,34, "boy"),("another",345,47,"boy", "last")
]
How do u get each value from it like 
Output 
name
2344
34
...

What i did was 
for row in list_tuple:
for row2 in row:
return row

But i get error  too many value to unpack 

Please help

Sent from my iPhone
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] List of tuples

2016-04-20 Thread isaac tetteh
This a flask app that I am connecting to the mysql 

@app.route("/viewSingle", methods=['POST','GET'])
def SingleView():
formB=singleView()
data=[]
if request.method=="POST":
if formB.validate_on_submit:
#if request.form['submit']=="View CONTINENT":
c,conn = connection()
c.execute('''select * from Country''')
data = c.fetchall()
data=list(data)
for row in data:
for a in row:
return row  //this is the problem
#return str(data) 
#data=list(data)
c.close ()
conn.close ()
#return data
return render_template("view.html",data=data,formB=formB)

error 
ValueErrorValueError: too many values to unpackTraceback (most recent call 
last)File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1836, in __call__return self.wsgi_app(environ, start_response)File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1820, in wsgi_appresponse = self.make_response(self.handle_exception(e))File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1403, in handle_exceptionreraise(exc_type, exc_value, tb)File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1817, in wsgi_appresponse = self.full_dispatch_request()File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1478, in full_dispatch_requestresponse = self.make_response(rv)File 
"/home/isaac/flasky/project_1/lib/python2.7/site-packages/flask/app.py", line 
1563, in make_responserv, status, headers = rv + (None,) * (3 - 
len(rv))ValueError: too many values to unpack


> From: d...@hashcollision.org
> Date: Tue, 19 Apr 2016 15:01:41 -0700
> Subject: Re: [Tutor] List of tuples
> To: itette...@hotmail.com
> CC: tutor@python.org
> 
> On Tue, Apr 19, 2016 at 1:56 PM, isaac tetteh  wrote:
> > I have a list like this
> > [
> > ("name",2344,34, "boy"),("another",345,47,"boy", "last")
> > ]
> > How do u get each value from it like
> > Output
> > name
> > 2344
> > 34
> > ...
> >
> > What i did was
> > for row in list_tuple:
> > for row2 in row:
> > return row
> >
> > But i get error  too many value to unpack
> 
> 
> Hi Issac,
> 
> Can you copy and paste the exact error message and stack trace that
> you're seeing?  Try not to paraphrase it: we need to see exactly the
> text is saying.  In some cases, we'll even pay attention to whitespace
> and other insanely silly details.  :P
> 
> Since that's tedious for you to retype, just use copy-and-paste.
> Include everything that the error message says, even if it doesn't
> make sense to you.  We'll try to help you interpret what the error is
> saying.  Unfortunately, you paraphrased the error message above too
> much: I have no good guesses from what you've presented so far.
> 
> Also, try to show the entire program that you ran as well.  The
> snippet you showed us is incomplete, because we don't know how the
> program defines "list_tuple".  Generally, you want to include enough
> detail when asking for help that it's really easy for the tutors here
> to "reproduce" your problem.  That way, we can see the same problem
> that you see.  That's important.
> 
> 
> My best guess so far, from all that you've shown us, is that a
> *different* part of the program is responsible for the error you're
> showing us.  That's why we need more details: I think something else
> other than what you're showing us is producing that error.  The reason
> I think so is because no part of the program you're showing us is
> doing tuple unpacking, at least from what I can tell.
  
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: List of tuples

2016-04-20 Thread isaac tetteh

> From: isaac tetteh 
> Date: April 19, 2016 at 9:05:04 PM CDT
> To: Danny Yoo 
> Subject: Re: [Tutor] List of tuples
> 
> Thanks things are working good now. The only problem is i want to print the 
> for loop output on one line instead of on each line.
> Example [1,2,3,4,5]
> Output 
> 1 2 3 4 5 
> I would to do this in Jinja 
> 
> Sent from my iPhone
> 
>> On Apr 19, 2016, at 8:35 PM, Danny Yoo  wrote:
>> 
>> Okay, in the context of a function, the error you're seeing makes more sense.
>> 
>> You need to ensure that the return value of the function is of the right 
>> type.  In  SingleView, the intended return value appears to be a structured 
>> response value.  
>> 
>> Given that, then any other return statements in the body of the function are 
>> suspect: return is a statement that will finish a function.
>> 
>> If a function returns a value of a tour that it isn't supposed to, expect 
>> that to produce very strange error messages.  That's essentially what you're 
>> seeing.
>> 
>> Looking at the construction of the response at the end:
>> 
>> > return render_template("view.html",data=data,formB=formB)
>> >
>> 
>> I'm wondering: perhaps you can collect the extracted column and add it as an 
>> additional value in you're template?
>> 
>> If you have questions, please feel free to ask.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Is there a library which has this object?

2016-04-29 Thread isaac tetteh
Im sure its not working because array is not in function. paste the error 
message here im sure someone will give u a better answer

Sent from my iPhone

> On Apr 28, 2016, at 4:07 PM, Yeh  wrote:
> 
> Thank you!
> 
>> You probably want to look at the itertools module.
>> 
>> There you can find among others the count() generator function.
>> Others of possible interest include cycle() and repeat()
> Yeah, I'm going to check them now.and I just solved my first question by 
> using numpy, as below:
> import timeimport numpy as np
> start = input("please input the value of start: ")end = input("please input 
> the value of end: ")dur = input("please input the value of dur: ")array = 
> np.linspace(float(start),float(end),1000)dur = float(dur)/len(array)for i in 
> array:print(float(i))time.sleep(dur)
> But, how to make it become a function?I tried to:def 
> myFunction(start,end,dur):...for i in array:return i
> time.sleep(dur)
> as you see, I failed...
> Thanks again!
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Sorting a list in ascending order

2016-04-29 Thread isaac tetteh
You can use sorted(line) but you result will be in a list if thats okay. 
Otherwise you can iterate the list. 

Sent from my iPhone

> On Apr 29, 2016, at 3:03 PM, Ken G.  wrote:
> 
> In entering five random number, how can I best sort
> it into ascending order, such as 0511414453? Using
> Linux 2.7.6 in Ubuntu 14.04.4. Thanks.
> 
> number01 = "41"
> number02 = "11"
> number03 = "05"
> number04 = "53"
> number05 = "44"
> line = number01 + number02 + number03 + number04 + number05
> print
> print line
> line.sort()
> print
> print line
> 
> 
> 4111055344
> 
> Traceback (most recent call last):
>  File "Mega_Millions_01_Tickets_Entry_TEST_TEST.py", line 11, in 
>print line.sort()
> 
> AttributeError: 'str' object has no attribute 'sort'
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Issues converting a script to a functioin (or something) [SOLVED]

2016-05-01 Thread isaac tetteh
You have two arguments in you function but when you call the function no 
argument is set in. Take the arguments out from the function if you want to use 
the the values from the user. 

Sent from my iPhone

> On May 1, 2016, at 8:41 AM, Olaoluwa Thomas  wrote:
> 
> Hi Bob,
> 
> Thanks for your feedback. Please do not hesitate to provide more as I shall
> email you personally in the future.
> 
> The script is made up of a function definition and its call prompting the
> user for input.
> 
> The script itself takes "number of hours worked" and "hourly rate" as
> inputs and gives gross pay as a product of the two.
> As I stated in my earlier email, there is also a portion for calculating
> gross pay with considerations for overtime (> 40 hours worked).
> 
> The problem was that running the code gave an error which I now do not
> remember in detail as I have moved on after having fixed it.
> 
> Here's the initial email below with Sreenathan's helpful input followed by
> my amendments to the code:
> (I thought my initial email was quite self-explanatory but what do I
> know... Please read through to the end)
> 
> On Sun, May 1, 2016 at 1:09 PM, Sreenathan Nair 
> wrote:
> 
>> On Sun, May 01, 2016 at 5:34 PM, Olaoluwa Thomas 
>> wrote:
>> 
>> The novice Python programmer is back.
>> 
>> I'm trying to incorporate a function and its call in the GrossPay.py
>> script
>> that Alan solved for me.
>> It computes total pay based on two inputs, no. of hours and hourly rate.
>> 
>> There's a computation for overtime payments in the if statement.
>> 
>> Something seems to be broken.
>> 
>> Here's the code:
>> def computepay(hours, rate):
>>hours = float(raw_input ('How many hours do you work?\n'))
>>rate = float(raw_input ('What is your hourly rate?\n'))
>>if hours > 40:
>>gross = ((hours - 40) * (rate * 1.5)) + (40 * rate)
>>elif hours >= 0 and hours <= 40:
>>gross = hours * rate
>>print "Your Gross pay is "+str(round(gross, 4))
>> 
>> computepay()
>> 
>> What am I doing wrong?
>> 
>> *Warm regards,*
>> 
>> *Olaoluwa O. Thomas,*
>> *+2347068392705*
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
>> 
>> Hi,
>> The parameters hours and rate are required when calling the method
>> computepay ex: computepay(8, 200), so basically computepay() by itself will
>> throw an error  Also, as a suggestion if you're gonna get hours and
>> rate via user input perhaps they can be removed from the method definition?
>> 
>> ​Thanks, Sreenathan. These alterations solved it.
> 
> def computepay(hours, rate):
>if hours > 40:
>gross = ((hours - 40) * (rate * 1.5)) + (40 * rate)
>elif hours >= 0 and hours <= 40:
>gross = hours * rate
>print "Your Gross pay is "+str(round(gross, 4))
> computepay(hours = float(raw_input ('How many hours do you work?\n')), rate
> = float(raw_input ('What is your hourly rate?\n')))
> 
> *Warm regards,*
> 
> *Olaoluwa O. Thomas,*
> *+2347068392705*
> 
>> On Sun, May 1, 2016 at 2:13 PM, Bob Gailer  wrote:
>> 
>> 
>> On May 1, 2016 8:04 AM, "Olaoluwa Thomas" 
>> wrote:
>>> 
>>> The novice Python programmer is back.
>> Welcome back. We are here to help you when you are stuck. Telling us
>> something is broken is not adequate. Tell us-what you are expecting the
>> program to do and what results you're getting.
>>> 
>>> I'm trying to incorporate a function and its call in the GrossPay.py
>> script
>>> that Alan solved for me.
>>> It computes total pay based on two inputs, no. of hours and hourly rate.
>>> 
>>> There's a computation for overtime payments in the if statement.
>>> 
>>> Something seems to be broken.
>>> 
>>> Here's the code:
>>> def computepay(hours, rate):
>>>hours = float(raw_input ('How many hours do you work?\n'))
>>>rate = float(raw_input ('What is your hourly rate?\n'))
>>>if hours > 40:
>>>gross = ((hours - 40) * (rate * 1.5)) + (40 * rate)
>>>elif hours >= 0 and hours <= 40:
>>>gross = hours * rate
>>>print "Your Gross pay is "+str(round(gross, 4))
>>> 
>>> computepay()
>>> 
>>> What am I doing wrong?
>>> 
>>> *Warm regards,*
>>> 
>>> *Olaoluwa O. Thomas,*
>>> *+2347068392705*
>>> ___
>>> Tutor maillist  -  Tutor@python.org
>>> To unsubscribe or change subscription options:
>>> https://mail.python.org/mailman/listinfo/tutor
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Dictionary Question

2016-05-02 Thread isaac tetteh

For some reason i cant find reply all . But try this 
for key, value in mydic.items():
  If A==value:
   Print key
Nb: use iteritems() if using python2

Sent from my iPhone

> On May 2, 2016, at 4:29 PM, Jason N. via Tutor  wrote:
> 
> Hello,
> Wanted to ask if its possible to have a dictionary that can be looked up by 
> either values?
> For example, 
> mydic = {"A: "Apple", "B": "Banana"}When user inputs "A" I want "Apple" to 
> come. But if the user enter "Apple" I want "A" to respond.
> Please let me know the best way to handle this type cause instead of just 
> created duplicate entries to cover all possibilities. Thank you.
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Dictionary Question

2016-05-02 Thread isaac tetteh
Sorry for the if statement the correct statement should be "if 'apple' ==value:"

Sent from my iPhone

> On May 2, 2016, at 4:58 PM, isaac tetteh  wrote:
> 
> 
> For some reason i cant find reply all . But try this 
> for key, value in mydic.items():
>  If A==value:
>   Print key
> Nb: use iteritems() if using python2
> 
> Sent from my iPhone
> 
>> On May 2, 2016, at 4:29 PM, Jason N. via Tutor  wrote:
>> 
>> Hello,
>> Wanted to ask if its possible to have a dictionary that can be looked up by 
>> either values?
>> For example, 
>> mydic = {"A: "Apple", "B": "Banana"}When user inputs "A" I want "Apple" to 
>> come. But if the user enter "Apple" I want "A" to respond.
>> Please let me know the best way to handle this type cause instead of just 
>> created duplicate entries to cover all possibilities. Thank you.
>> ___
>> Tutor maillist  -  Tutor@python.org
>> To unsubscribe or change subscription options:
>> https://mail.python.org/mailman/listinfo/tutor
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Dictionary Question

2016-05-02 Thread isaac tetteh
If only I understand what you mean. You can just make all the values in the 
dictionary lower, upper or capitalized. Then if you want take an input or 
whatever you want to do with it just use .lower() or .upper() or .capitalized() 
to convert it to what is in the dictionary. Maybe someone has a better way to 
do it :) 


Sent from my iPhone

> On May 2, 2016, at 7:59 PM, Jason N. via Tutor  wrote:
> 
> Thank you all for your responses. 
> A quick follow up, what is the best way to make dictionary requests case 
> in-sensitive? For example, "Apple and "apple" should bring back the same 
> dictionary response. Thank you. 
> 
>On Monday, May 2, 2016 6:57 PM, Bob Gailer  wrote:
> 
> 
> 
> 
>> On May 2, 2016 5:27 PM, "Jason N. via Tutor"  wrote:
>> 
>> Hello,
>> Wanted to ask if its possible to have a dictionary that can be looked up by 
>> either values?
>> For example, mydic = {"A: "Apple", "B": "Banana"}
>> When user inputs "A" I want "Apple" to come. But if the user enter "Apple" I 
>> want "A" to respond.
> I think this would depend on how big the data set is and how often you want 
> to look things up.
> Two other Solutions: 
> Create a class which internally manages two dictionaries.
> If things are really big create a database using for example sqlite.
> 
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] Fwd: Fwd: Re: need help

2016-08-12 Thread isaac tetteh
Also use good text editor like sublimeText. It will do the indentation for you.


Begin forwarded message:

> From: Alan Gauld via Tutor 
> Date: August 12, 2016 at 11:37:11 AM CDT
> To: tutor@python.org
> Subject: Re: [Tutor] Fwd: Re: need help
> Reply-To: Alan Gauld 
> 
> 
>> -- Forwarded message --
>> From: "Pallab Amway" 
>>> Respected sir,lots of thanks for your advice,but while i am compiling
>>> those programe with python 2.7 no output is coming only showing the
>>> masage "expected indented block"
> 
> The first thing is to point out that you are getting an output - an
> error message. Error messages are output.
> 
> The error tells you that it expects an indented block.
> Do you understand what that means? Indentation refers
> to the amount of spacing before the text. specifically
> there must be more space before the lines after a control
> statement (like your 'if') than there is on the control
> line.
> 
> In most programming languages this is a matter of good
> style to make the code easier for humans to read.
> But it is a fundamental principle in python because
> the compiler uses the spacing to figure out how much
> code is influenced by the control statement.
> 
> So an if statement should look like:
> 
> 
> if :
>an indented line
>another indented line
>end of if block
> elif Yet another indented line
>only executed if the elif test is true
> else:   # optional else
>More indented lines
>only executed when the if and elif parts are false.
> 
> The same applied to other control statements in Python
> such as 'for', 'while', 'def', 'try' etc, etc.
> 
> The amount of extra space you apply is up to you
> but the recommended size is 4 spaces (as above).
> 
>> can you sugest any ebook?and please
> 
> I am biased but you can try my tutorial (see .sig below)
> or there is a full page for beginners on the python.org
> web site
> 
> https://www.python.org/about/gettingstarted/
> 
> 
> -- 
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
> 
> 
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Need reference materials to learn flask + python for payroll project that would run both in windows (PC) and android/iOS.

2016-09-13 Thread isaac tetteh
"Project that will run on both windows and android/iso" if mean its 
responsiveness then flask cannot do that but css3, javascript(Angular), 
twitter-bootstrap can help you do that. But if you mean like a desktop/ phone 
app then maybe check another framework.
Check out
Flask Web Development: Developing Web Applications with Python
By Miguel Grinberg



Sent from my iPhone
On Sep 13, 2016, at 7:28 PM, Alan Gauld via Tutor 
mailto:tutor@python.org>> wrote:

On 13/09/16 21:11, Glen Reytas wrote:

I have a basic knowledge in Python and I would like to enhance it by
engaging in a payroll project. For you to gauge my coding level, I finished
the Python course at codecademy.com but it was 2-3 years 
ago. Since then I
haven't coded aside from HTML.

I don;t have a lot on Flask, I only read the tutorial stuff
on the Flask web site and watched a couple of YouTube videos.

So, I would appreciate if you could provide me a series of topics that
would help me code my first python project and be online at the end of it.

To build a payroll application requires quite a lot of skills, usually
including a database of some kind and a lot of security type stuff. Do
you have experience in either of those areas? Also you need to test it
really thoroughly, especially around areas involving legal rules (like
taxes, overtime rates, max/min hours etc etc.) It's not something I'd
choose as a first project unless you are only doing a very simplistic
payslip viewer or similar - and even then data protection legislation
will likely still be applicable.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Adding numbers within a string

2016-10-12 Thread isaac tetteh
def foo(x):
a,b = (0,"")
for i in x:
if i != " ":
b+=i
else:
print ("this is b",b)
a = a + int(b)
print ("this is a",a)
b = ""
print ("final a ",a)


this should help you solve it. figure a way to add the last number. if any 
troubles ask again.
Thanks [😊]


From: Tutor  on behalf of Bob 
Gailer 
Sent: Wednesday, October 12, 2016 2:26 PM
To: LQ Soh
Cc: tutor@python.org
Subject: Re: [Tutor] Adding numbers within a string

On Oct 12, 2016 4:09 AM, "LQ Soh"  wrote:
>
> To whom it may concern,
> Can someone enlighten me as to how you can create a function such
> that sum_numbers('10 5 8'), when run, will give an answer of 23, without
> using str.split() and using a for loop

def sum_numbers(x):
for x in [1]:
print(23)

Your instructor will probably be displeased with that answer, but it meets
the requirements.

It would be nice if our teachers could models writing good requirements.

What do you think a good requirement statement would be?
___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
Tutor Info Page - mail.python.org Mailing 
Lists
mail.python.org
This list is for folks who want to ask questions regarding how to learn 
computer programming with the Python language and its standard library.



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Tutor Info Page - mail.python.org Mailing 
Lists
mail.python.org
This list is for folks who want to ask questions regarding how to learn 
computer programming with the Python language and its standard library.



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] (regular expression)

2016-12-10 Thread isaac tetteh
this is the real code


with 
urllib.request.urlopen("https://www.sdstate.edu/electrical-engineering-and-computer-science";)
 as cs:
cs_page = cs.read()
soup = BeautifulSoup(cs_page, "html.parser")
print(len(soup.body.find_all(string = ["Engineering","engineering"])))

i used control + f on the link in the code and i get 11 for ctrl + f and 3 for 
the code

THanks





From: Tutor  on behalf of Bob 
Gailer 
Sent: Saturday, December 10, 2016 7:54 PM
To: Tetteh, Isaac - SDSU Student
Cc: Python Tutor
Subject: Re: [Tutor] (no subject)

On Dec 10, 2016 12:15 PM, "Tetteh, Isaac - SDSU Student" <
isaac.tet...@jacks.sdstate.edu> wrote:
>
> Hello,
>
> I am trying to find the number of times a word occurs on a webpage so I
used bs4 code below
>
> Let assume html contains the "html code"
> soup = BeautifulSoup(html, "html.parser")
> print(len(soup.find_all(string=["Engineering","engineering"])))
> But the result is different from when i use control + f on my keyboard to
find
>
> Please help me understand why it's different results. Thanks
> I am using Python 3.5
>
What is the URL of the web page?
To what are you applying control-f?
What are the two different counts you're getting?
Is it possible that the page is being dynamically altered after it's loaded?
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Tutor Info Page - Python
mail.python.org
This list is for folks who want to ask questions regarding how to learn 
computer programming with the Python language and its standard library.



___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Installing Python3.6.1 on Ubuntu 16.04.2

2017-07-02 Thread isaac tetteh
Sudo apt install Python 3.6 should be enough. But I would advise to use a 
virtual environment since you don't want to mess up Ubuntu configuration.

Sent from my Verizon LG Smartphone

-- Original message--
From: Joseph VOGTEMBING via Tutor
Date: Sun, Jul 2, 2017 2:48 PM
To: tutor@python.org;
Cc:
Subject:[Tutor] Installing Python3.6.1 on Ubuntu 16.04.2

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Help with loops

2018-05-01 Thread Isaac Tetteh
Hi Shannon,



Yes there is a way. First in my opinion I think queue.json is not really a JSON 
data structure but just a list of list. If you are able to read it then I 
that’s great.



One way to solve this is doing something like below:



queue = [

["James Bruce", "Bananas"],

["Katherine Newton", "Bananas"],

["Deborah Garcia", "Pears"],

["Marguerite Kozlowski", "Pineapples"],

["Kenneth Fitzgerald", "Pineapples"],

["Ronald Crawford", "Bananas"],

["Donald Haar", "Apples"],

["Al Whittenberg", "Bananas"],

["Max Bergevin", "Bananas"],

["Carlos Doby", "Pears"],

["Barry Hayes", "Pineapples"],

["Donald Haar", "Bananas"]

]



stock = {"Apples": 14,

  "Bananas": 14,

  "Pineapples": 0,

  "Pears": 8}



for i in queue:

if stock[i[1]] > 0 :

print("Gave {} to {}".format(i[1],i[0]))

else:

print("Could not give {} to {}".format(i[1],i[0]))



Let us know if you have any other questions.



Isaac,





Sent from Mail for Windows 10




From: Tutor  on behalf of 
Shannon Evans via Tutor 
Sent: Monday, April 30, 2018 8:35:01 AM
To: tutor@python.org
Subject: [Tutor] Help with loops

Hi, is there any way that i can add a loop or iteration or something so
that i dont have to write out every person who has fruit. This information
is coming from the following json files:
*queue.json* file

[

  ["James Bruce", "Bananas"],

  ["Katherine Newton", "Bananas"],

  ["Deborah Garcia", "Pears"],

  ["Marguerite Kozlowski", "Pineapples"],

  ["Kenneth Fitzgerald", "Pineapples"],

  ["Ronald Crawford", "Bananas"],

  ["Donald Haar", "Apples"],

  ["Al Whittenberg", "Bananas"],

  ["Max Bergevin", "Bananas"],

  ["Carlos Doby", "Pears"],

  ["Barry Hayes", "Pineapples"],

  ["Donald Haar", "Bananas"]

]



*stock.json* file

{

"Apples": 14,

"Bananas": 14,

"Pineapples": 0,

"Pears": 8

}

This is what i've done so far:

import json

#Load the stock and queue files
queue=json.load(open("queue.json"))
stock=json.load(open("stock.json"))

if (stock[queue[0][1]]>0):
#in stock
print "Gave Bananas to James Bruce"
else:
print "Could not give Bananas to James Bruce"

if (stock[queue[1][1]]>0):
#in stock
print "Gave Bananas to "+ queue[1][0]
else:
print "Could not give Bananas to "+ queue[1][0]

if (stock[queue[2][1]]>0):
#in stock
print "Gave Pears to "+ queue[2][0]
else:
print "Could not give Pears to "+ queue[2][0]

if (stock[queue[3][1]]>0):
#in stock
print "Gave Pineapples to "+ queue[3][0]
else:
print "Could not give Pineapples to "+ queue[3][0]

Thanks
Shannon
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor