Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 08-17-2006, 11:40 AM   #1 (permalink)
melvin
Registered User
 
Join Date: Jul 2006
Posts: 3
melvin is on a distinguished road
Python Trouble

Hello everyone. I am making a conversion calcualtor in python and I am having trouble, what is wrong with my code:


print"""
Welcome to the conversion calculator!
"""
print"""
Please make a choise from the following options

1. Temperatures
2. Distance Rate and Time
"""
c1 = raw_input("Please type the number of your choise : ")
if c1 = 1:
print "You have selected temperatures"
melvin is offline   Reply With Quote
Old 08-17-2006, 07:23 PM   #2 (permalink)
melvin
Registered User
 
Join Date: Jul 2006
Posts: 3
melvin is on a distinguished road
Come on! I need help here!
melvin is offline   Reply With Quote
Old 08-17-2006, 10:37 PM   #3 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,694
redhead is on a distinguished road
Quote:
Come on! I need help here!
And I need to wake up after an all nite hacking spree

First of, you're using raw_input() this is for inputting strings, so your value to compare will be a type integer compared with a read string, so I'd suggest you use input() instead of raw_input()

Second, you're using the assignment operator for comparing c1 with your read value, this will not go.. so use
Code:
if c1 == 1:
this would make your program look like this:
Code:
#!/usr/bin/python

print "Welcome to the conversion calculator!"
print """
Please make a choise from the following options

1. Temperatures
2. Distance Rate and Time
"""

c1 = input("Please type the number of your choise : ")
if c1 == 1:
  print "You have selected temperatures"
And May I say, learning python as the first language of choice is a wise move... I'm glad to see that approach from you melvin
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
web log in using python prashmohan All Other Coding Languages 2 12-16-2005 12:46 AM
Python problem... slashdot All Other Coding Languages 0 02-01-2005 09:54 PM
New Tutorial: Python Lists Overview sde Code Newbie News 3 03-24-2004 09:54 AM
PyCon 2004 - Python Developers Conference sde Code Newbie News 0 02-12-2004 03:45 PM


All times are GMT -8. The time now is 01:46 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting