@sokoban4ever ευχαριστώ και πάλι...
τώρα πρόσεξα ότι ενώ είχα κάνει εγκατάσταση python3 με εισαγωγή στη κονσόλα python myprog.py έκανε χρήση python 2.6 και όχι του python3 όπου πολύ απλά όπως είπες μόνο με χρήση του input() αποφεύγεται το casting
#!/usr/bin/python
#-*- coding: utf-8 -*-
#Filename: break.py
while True:
s = (input('Enter something : '))
if s == 'quit':
break
print('Length of the string is', len(s))
print ('Done')
Enter something : something
Traceback (most recent call last):
File "break.py", line 6, in <module>
s = (input('Enter something : '))
File "<string>", line 1, in <module>
NameError: name 'something' is not defined
------------------
(program exited with code: 1)
Press return to continue
python3 break.py
Enter something : something
Enter something : "something"
$ python3
Python 3.1.2 (r312:79147, Mar 21 2010, 19:29:49)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> input("Your name: ")
Your name: Savvas
'Savvas'
$ python
Python 2.6.5 (r265:79063, Apr 3 2010, 01:56:30)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> raw_input("Your name: ")
Your name: Savvas
'Savvas'
stamatiou έγραψε:Εκείνο το κομμάτι με το προγραμμα while εμένα μου το βγάζει λάθος, γιατί?
def total(initial=5, *numbers, **keywords):
count = initial
for number in numbers:
count += number
for key in keywords:
count += keywords[key]
return count
print(total(10, 1, 2, 3, vegetables=50, fruits=100))