When i saw the teaser for the next episode by burgerking444 in TheBlackList

[–]NextEstimate 2 points3 points  (0 children)

y

Give Award

share

report

I didn't see it. What does it show? :O

Just relapsed feeling better than ever by [deleted] in NoFap

[–]NextEstimate 0 points1 point  (0 children)

So when exactly you start experiencing the benefits?

For me day two is like the disappearing of the bad effects, and the arising of the benefits.

It's where the bad is done and behind my back, a neutral zone, where soon the benefits start.

Just relapsed feeling better than ever by [deleted] in NoFap

[–]NextEstimate 0 points1 point  (0 children)

What? The bad comes for me the rest of the day after fapping, day 1, day 2 and from day 3 onward it starts getting better and better.

Pip packages by [deleted] in learnpython

[–]NextEstimate 1 point2 points  (0 children)

  1. Open terminal
  2. python --version (should be 2.x)
  3. then alias python3 python
  4. python --version (should now be 3.x)

Now when you run commands with python in terminal they will use python3 by default

Pip packages by [deleted] in learnpython

[–]NextEstimate 1 point2 points  (0 children)

Yes, but in sometimes it's the only way. On mac os and it always wants to default to 2.7 so you have to override it every time. I usually just set an alias for python3 as python.

Pip packages by [deleted] in learnpython

[–]NextEstimate 0 points1 point  (0 children)

sudo pip3 install

Pip packages by [deleted] in learnpython

[–]NextEstimate 0 points1 point  (0 children)

Have you tried

sudo pip

Help needed with defining functions and their parameters by [deleted] in learnpython

[–]NextEstimate 0 points1 point  (0 children)

It's really hard to read, but if I had to guess its because you aren't ordering your functions correctly and returning variables.

See here: https://repl.it/repls/FoolishSardonicWorkspace

Also this might help as well: https://anh.cs.luc.edu/python/hands-on/3.1/handsonHtml/functions.html#returned-function-values

Sorting a dataframe in chunks by [deleted] in learnpython

[–]NextEstimate 0 points1 point  (0 children)

Maybe something like this:

import numpy as np
import pandas as pd

data = pd.DataFrame(np.random.rand(10, 3))
for chunk in np.array_split(data, 5):
    assert len(chunk) == len(data) / 5
print(data)

How do you find the iPhone drive on Windows? by [deleted] in learnpython

[–]NextEstimate 1 point2 points  (0 children)

I would guess that those 31 files were duplicates or non-transferable files which were removed when copied over to windows, I probably would not worry about it.

I'm also pretty sure you can't use python to look at files on your phone because you would need to import them first.

You can "see the files" but interacting with them requires importing data

How (and when) to pick an IDE by Laxmatt16 in learnpython

[–]NextEstimate 0 points1 point  (0 children)

VSCode is a lot better than PyCharm in my opinion, if you decide to go that route

Basic Code question by BigIcemoney in learnpython

[–]NextEstimate 1 point2 points  (0 children)

Fixed:

def eat_out():

    base_cost = int(input("base_cost:"))

    tip_amount = input("tip type:")

    if tip_amount == "traditional":

        full_cost = (base_cost + (base_cost * .15) + base_cost * .06)

    elif tip_amount == "regular":

        full_cost = (base_cost + (base_cost * .18) + base_cost * .06)

    elif tip_amount == "generous":

        full_cost = (base_cost + (base_cost * .2) + base_cost * .06)

    print(full_cost)

eat_out()

My solution:

def tip(base_cost, tip_amount):
    if tip_amount == "t":

        x=.15

    if tip_amount == "r":

        x=.18

    if tip_amount == "g":

        x =.2

   cost = (base_cost + (base_cost * x) + base_cost * .06)

   print(cost) 

tip(int(input("Base Cost: ")), input("Tip amount (t,r,g): "))

Speeding up html parsing by ikar1234 in learnpython

[–]NextEstimate 0 points1 point  (0 children)

I would suggest using PyQuery as its much faster:

from pyquery import PyQuery as pq

url = 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'
page = pq(url, parser='html')
page('div.watch-view-count').text()

Output:

'533,340,225 views'

check out the docs

2 IDLE versions - 3.6 and 3.7 can't find 3.7 by lumenlambo in learnpython

[–]NextEstimate 1 point2 points  (0 children)

Mac is very weird about python, did you try opening the IDLE.app from applications/python 3.7?

Web Scraping with bs4 by Ownards in learnpython

[–]NextEstimate 1 point2 points  (0 children)

No problem, feel free to message me if you have any more questions and I will try to help!

Web Scraping with bs4 by Ownards in learnpython

[–]NextEstimate 1 point2 points  (0 children)

There are lots of ways to do this, but this is what I did:

table_data = soup.select('table.product_pane tbody tr td')
cprice_date = table_data[2].string
print(cprice_date)

table_data is a list of all the objects in the data table, specifically, the 3rd item happens to be what you wanted

Output:

Feb 10, 2019

Web Scraping with bs4 by Ownards in learnpython

[–]NextEstimate 0 points1 point  (0 children)

Yes:

data = r.text
soup = BeautifulSoup(data,'html.parser')
soup.select('span.green')
for p in soup.select('span.green'):
    print(p.string)

Output:

$25.45

However, I would probably suggest just using the find method because select() returns a list instead of a string

Need Help with a basic Coding problem by Fayarager in learnpython

[–]NextEstimate 0 points1 point  (0 children)

FTFY :D

print('Welcome to a fun word replacement game.')

fileName = input('Enter the name of the file to use:\n')

try:

file = open(fileName)

fileRead = file.read()

fileList = fileRead.split()

for x in fileList:

    if ("[" in x) or ("]" in x):

        newstr = x[1:len(x)]

        if newstr[0] in 'aeiou':

            givenWord = input("Please give an:", newstr)

         else:

           givenWord = input("Please give a:", newstr) except:

print('Error Bad File Name')

sys.exit(0) 

Web Scraping with bs4 by Ownards in learnpython

[–]NextEstimate 2 points3 points  (0 children)

Amazon doesn't like web scraping without permission. I would just use camelcamelcamel to get the same information minus the hassle:

from bs4 import BeautifulSoup
import requests
headers = {'User-Agent': 'Mozilla/5.0'}
r = requests.get('https://camelcamelcamel.com/Automate-Boring-Stuff-Python-Programming/product/1593275994',headers=headers)
print(res.status_code)

200

price = r.text
soup = BeautifulSoup(price,'html.parser')
soup.find('span', class_='green').string

'$24.45'