hehe ok I just found out how to do it, while randomly trying out stuff.
>type(x) returns the data type of x
so:
> fg=[2,5,3,"hello"]
> print type(fg)
would give you:
> <type 'list'>
~ Mo
User Profile
Collapse
-
data types
I was wondering if there is a way of finding out what kind of data type a variable in python is storing?
Something like:
> print datatype(x)
perhaps?
Which should return string, integer, float or list etc.
~ Mo -
Ok it's all working now, thanks again. Just need to do sth about my algorithm now... going through 10 ^ 81 possibilities, of which a bazillion are totally irrelevant, by brute force just isn't quite the right thing :P
Anyway it works if u put in like de first 76 numbers... u'd only have to wait about a minute then, till de program pops up with an answer... hehe (^ - ^')
But back to the topic. Wouldn't one expect, just by intuition...Leave a comment:
-
-
Odd list behaviour
Hi!
I'm coding a program that's supposed to solve Sudoku, but came accross a really odd behaviour of lists.
comparelist is a 2D list (9 x 9) filled with integers and unsorted (and I want it to stay that way)
>for i in range(9):
>>> bufferlist=comp arelist[i]
>>> bufferlist=sort er.sortiere(buf ferlist,0,len(b ufferlist)-1) # sorts a list
>>> if bufferlist==che cklist:... -
Probably out of date, but anyway: the program sure is written correctly. And there are about a bazillion other ways of writing it, but de algorithm would stay de same.
For instace:
>from math import *
>
>def area_of_pizza() :
> diameter = input("Enter the diameter of the pizza: ")
> radius = 1.0/2.0 * diameter
> a = pi * (radius ** 2) # ** is to the power...Leave a comment:
No activity results to display
Show More
Leave a comment: