
I have the attached code and keep getting an unexpected indent error on the last line, how can I fix this?
CODE:
import urllib
import re
url=input("Enter the URL:") #raw_input() became input() in
python3
req=request(url)
while True:
try:
counts=dict()
fhand=urllib.urlopen(req)
for line in fhand:
words=line.split()
for word in words:
counts[word]=counts.get(word,0)+1
print(counts)
data=count.getlength(512)
if(len(data)<1):
break
print(data)
except: # I have added these two lines to remove the error
pass
I have the attached code and keep getting an unexpected indent error on the last line,...
I have the current code that is working. I need to edit it so that I am
only counting strings that are after the word 'From' in a text
file. Right now it's counting all words, but I just need the From
email addresses in a text file. I think the issue if in the if/else
loop but nothing I have tried works. Please help!
1 import string 2 fhand open('C: \Users \Brooke\Canopy scripts mbox-short.txt') 3 counts dict( 4 for...
I cant get this python program to read all the unique words in a file. It can only read the number of the unique words in a line. import re import string from collections import Counter # opens user inputted filename ".txt" and (w+) makes new and writes def main(): textname = input("Enter the file to search: ") fh = open(textname, 'r', encoding='utf-8' ) linecount = 0 wordcount = 0 count = {} print("Sumary of the", fh) for line in...
Topic: Java Programming Hello, I have the following code attached below, and keep getting told that "Television" on the 23rd line "cannot be resolved to a type". It happens on this line of code... Television portable = new Television("Sharp", 19); Can you tell me how to fix this? Beginning of code... import java.util.Scanner; public class TelevisionDemo { {} public static void main(String[] args) { // //create a Scanner object to read from the keyboard Scanner keyboard = new Scanner(System.in); //...
Hi I am using python and I keep getting this error with my code. Traceback (most recent call last): ['1'] Traceback (most recent call last): File "/Users/isabellawelch/Python ish/shuffle.py", line 86, in <module> emp = Employee(emp_data[0], emp_data[1], emp_data[2], emp_data[3], emp_data[4]) IndexError: list index out of range What does it mean and how do i fix it?? from tkinter import Tk, Label, Button, Entry, END employees = [] class Employee: def __init__(self, empno, name, addr, hwage, hworked): self.empno = empno self.name =...
I am working on this code and keep getting errors like "ERROR: Syntax error: Encountered "<EOF>" at line 1, column 169." and "ERROR: Table/View 'STUDENT' does not exist. ERROR: Table/View 'STUDENT' does not exist. ERROR: Table/View 'STUDENT' does not exist." I do not know why this isn't working. Here is my code: DTCCDatabase.java import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; /** * This program creates the CoffeeDB database. */ public class DTCCDatabase { public static void main(String[] args)...
Python, I need help with glob. I have a lot of data text files and want to order them. However glob makes it in the wrong order. Have: data00120.txt data00022.txt data00045.txt etc Want: data00000.txt data00001.txt data00002.txt etc Code piece: def last_9chars(x): return(x[-9:]) files = sorted(glob.glob('data*.txt'),key = last_9chars) whole code: import numpy as np import matplotlib.pyplot as plt import glob import sys import re from prettytable import PrettyTable def last_9chars(x): return(x[-9:]) files = sorted(glob.glob('data*.txt'),key = last_9chars) x = PrettyTable() x.field_names =...
i have my code all the way complete except one syntax error code( import math f=open("101primes.txt") primes=[] for line in f: primes.append(int(line)) thelist=[2692493, 2692503, 4632703, 8767843, 7982119, 7983121, 13065521 , 11505341 ,11505343 ,14123649 ,14123651] for i in thelist: oof=1 TV=int(math.sqrt(i)) for x in primes: if(x>TV): break elif(i%x == 0): oof=0 break if(oof): print str(i)+ "is a prime number" else: print str(i)+ "is not a prime number" )
This is my code: import numpy as np import pandas as pd import sys from keras.models import Sequential from keras.layers import Dense from sklearn.preprocessing import StandardScaler from keras.layers.normalization import BatchNormalization from keras.layers import Dropout file_full=pd.read_csv("/Users/anwer/Desktop/copy/FULL.csv") file_bottom=pd.read_csv("/Users/anwer/Desktop/copy/bottom.csv") train=[] train_targets=[] test=[] test_targets=[] p=[] q=[] # We will generate train data using 50% of full data and 50% of bottom data. #is train target for labeling ? yes for train data train_df = file_full[:len(file_full)//2] labels=[ 0 for i in range(len(file_full)//2)] train_df=train_df.append(file_bottom[:len(file_bottom)//2]) for...
Python Modify your recommendation program so that it reports the titles of the works rather than their file names. To do this, write a program that reads in the titles.txt file and creates a dictionary that looks up the title using the file name. This dictionary should then be used to report the works by their title instead of their file name. Script to use: import os import math def count_word(table, word): 'for the word entry in the table, increment...
Hey I have a task which consists of two part. Part A asks for
writing a program of WORD & LINE CONCORDANCE
APPLICATION in python which I have completed it.
Now the second part has given 5 dictionary implementation codes
namely as: (ChainingDict, OpenAddrHashDict with linear probing,
OpenAddrHashDict with quadratic probing, and 2 tree-based
dictionaries from lab 12 (BST-based dictionary implementation) and
asks for my above program WORD & LINE CONCORDANCE
APPLICATION to use these implemented code and
show the time...