Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #98647

new to python, help please !!

Newsgroups comp.lang.python
Date 2015-11-11 08:34 -0800
Message-ID <93aef8e5-3d6f-41f4-a625-cd3c2007686e@googlegroups.com> (permalink)
Subject new to python, help please !!
From Anas Belemlih <anas.belemlih@gmail.com>

Show all headers | View raw


i am  a beginning programmer,  i am trying to write a simple code to compare two character sets in 2 seperate files. ( 2 hash value files basically)
idea is:
 open both files, measure the length of the  loop on.

if the length doesn't match, ==  files do not  match

if length matchs, loop  while comparing each character from each file if they match. 
 please tell me what i am doing wrong ?  i am using python 2.7

**********************************
hash1= open ("file1.md5", "r")
line1 =hash1.read()
hash2 = open("file2.md5","r")
line2= hash2.read()

number1 = len(line1)
number2 = len(line2)

#**************************
i=0
s1=line1[i]
s2=line2[i]
count = 0

if number1 != number2:
	print " hash table not the same size"
else:
    while count < number1:
	if s1 == s2:
		print " character", line1[i]," matchs"
		i=i+1
	count=count+1
	else
		print "Hash values corrupt"

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

new to python, help please !! Anas Belemlih <anas.belemlih@gmail.com> - 2015-11-11 08:34 -0800
  Re: new to python, help please !! John Gordon <gordon@panix.com> - 2015-11-11 16:58 +0000
  Re: new to python, help please !! Tim Chase <python.list@tim.thechases.com> - 2015-11-11 11:06 -0600
  Re: new to python, help please !! Ben Finney <ben+python@benfinney.id.au> - 2015-11-12 04:16 +1100
  Re: new to python, help please !! Quivis <quivis@domain.invalid> - 2015-11-11 17:48 +0000
    Re: new to python, help please !! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-11-12 13:58 +1100
      Re: new to python, help please !! Marko Rauhamaa <marko@pacujo.net> - 2015-11-12 08:21 +0200
        Re: new to python, help please !! Tim Chase <python.list@tim.thechases.com> - 2015-11-12 05:48 -0600
        Re: new to python, help please !! <paul.hermeneutic@gmail.com> - 2015-11-12 07:27 -0700
      Re: new to python, help please !! Quivis <quivis@domain.invalid> - 2015-11-12 17:55 +0000
        Re: new to python, help please !! Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-12 19:49 +0000
  Re: new to python, help please !! Peter Otten <__peter__@web.de> - 2015-11-12 15:56 +0100
  Re: new to python, help please !! Tim Chase <python.list@tim.thechases.com> - 2015-11-12 09:00 -0600
  Re: new to python, help please !! Peter Otten <__peter__@web.de> - 2015-11-12 16:41 +0100
  Re: new to python, help please !! Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-12 21:24 +0000

csiph-web