Problem by Dictonary with Variable and Input

i am writting a code that is counting random Numbers. Everytime when i change the value in the script, everything is working. But when im changing the variable to inpu with Summe = input("YourNumber"), it is not working. ``````import random import time #MyNumber = input("YourNumber") Summe = input("Suche deine Zahl") for i in range(1, 101): RamdomNumber = random.randrange(1, 4) globals()[f"Number{i}"] = RamdomNumber Dictonary = {k: v for k, v in globals().items() if not k.startswith("__")} print({k: v for k, v in globals().items() if not k.startswith("__")}) print(sum(value == Summe for value in Dictonary.values())) #Prozentsumme = Summe / 10 print("-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------") print("Deine Nummer ist:", MyNumber) #print("Deine Nummer gab es:", Summe , "Mal") #print("Die Wahrscheinlichkeit liegt bei:", Prozentsumme * 100 , "Prozent") `````` Please somebody help me!!!!

Submitted May 18th 2021 by Admin

A string will never equal an int -- if you're getting a number from `input()` and you want to compare it to an int value, convert it with `int()`. ``````import random Summe = int(input("Suche deine Zahl")) numbers = [random.randrange(1, 4) for _ in range(100)] for i, n in enumerate(numbers): print(f"Number{i+1}: {n}") print(sum(value == Summe for value in numbers)) print("Deine Nummer gab es:", Summe, "Mal") ``````

Relevant Questions

How to remove one element from list while iterate

September 19th 2021

Python Object Changing For No Apparent Reason

September 19th 2021

Multipy character position by ord() value of that character

September 16th 2021

I want to add a phrase "the Great" before every name in list names, why this did not work?

September 14th 2021

Filter function in Python (simple question)

September 13th 2021