So I'm a bit of a Python beginner and I am wondering if there is a way to modify or fix this script so that it generates random number/letter sequences. I think I've got the actual generation solved, but I need some help on how to print the result to the console. Here is my code:
def main():
import random
random.random() * 10
myList = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
random.choice(myList)
print(random.random() * 10 + random.choice(myList))
main()
Can any of you guys help me out? as I said before, I am a beginner, so it might be a basic mistake and examples in answers would be great.
Error edited in:
line 9, in main print(random.random() * 10 + random.choice(myList)) TypeError: unsupported operand type(s) for +: 'float' and 'str'
random.random()*10andrandom.choice(mylist)- you are calling methods and do not use thereturns. What do you want to achieve with those calls? The lastprintstatement will not work, you have to make a stringstr(93.2923)from your random float first - before you concattenate it with a string by using+