Guessing Game: computer generated number between 1 and 100 guessed by user
The pythonic way to do count = count + 1 is count += 1
You don't need to repeat the 'guess again' part of the game twice:

if guess &gt; val:
    print("Too high. Try again:", guess)  
elif guess &lt; val:
    print("Too low. Try again:", guess)
guess = int(input("\n\t\tEnter a number between 1 and 100: "))
count += 1
if guess == val:
    print("\nCongratulations! You got it in", count, "guesses.")
    break

You don't need to add the extra if statement because if guess != val, then the loop with break anyway:

while guess != val:
    if guess &gt; val:
        print("Too high. Try again:", guess)  
    elif guess &lt; val:
        print("Too low. Try again:", guess)
    guess = int(input("\n\t\tEnter a number between 1 and 100: "))
    count += 1
print("Congratulations! You got it in", count, "guesses.")

I think print("randint is", val) was probably for testing purposes, but it's still in your code!
If you execute your program outside the command module (I'm not quite sure what it's called), the program will close immediately after it's finished; it's always best to give the user the choice of when to quit, so insert this at the end of your code:

input("Press enter to quit")

The first section is unneeded:

def main():`, `if __name__ == "__main__":

The first if statement is also unneeded:

if guess == val:

You don't need to define guess = 0 the first time.


So, all in all, my improvement of your code is:

import random
print("Time to play a guessing game.")
val = random.randint(1, 100)
count = 1    
guess = int(input("\n\t\tEnter a number between 1 and 100: "))
while(guess != val):    
    if guess &gt; val:
        print("Too high. Try again:", guess)    
    elif guess &lt; val:
        print("Too low. Try again:", guess)
    guess = int(input("\n\t\tEnter a number between 1 and 100: "))
    count += 1
print("\nCongratulations! You got it in ", count, " guesses.")
input("Press enter to quit.")