wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
random.sqrt(75) | import random
random.sqrt(75) | Import module first. | Python |
if y = 47 {{}} | if y == 47 {{}} | Use ==. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
z = 4 | z=4 | No spaces. | Shell |
class Person {{ int z; }}; | class Person {{ public: int z; }}; | Make public. | C++ |
if (index = 62) | if (index == 62) | Use ==. | R |
97y = 10 | y97 = 10 | Variable cannot start with digit. | Python |
'test' + 90 | 'test' + 90.to_s | Convert int. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
WHERE name = '50' | WHERE name = 50 | Don't quote integer. | SQL |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if y > 100
print('hello') | if y > 100:
print('hello') | Colon missing after if. | Python |
function test(b)
print(b)
end | function test(b)
print(b)
end | Correct. | Lua |
x == '52' | x === 52 | Use strict equality. | JavaScript |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<note><age>value</age><name>39</name></note | <note><age>value</age><name>39</name></note> | Add closing >. | XML |
class Order {{ int y; }}
obj.y=5; | class Order {{ public int y; }}
obj.y=5; | Make field public. | Java |
if (a = 96) {} | if (a == 96) {} | Use ==. | Dart |
let num: number = 'hello'; | let num: string = 'hello'; | Fix type. | TypeScript |
const obj:Person = {{name:'value'}}; | const obj:Person = {{name:'value', age:9}}; | Add missing property. | TypeScript |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
my @arr = (4,55,96); | my @arr = (4,55,96); | Correct. | Perl |
'data' + 53 | 'data' + str(53) | Can't add int to string. | Python |
if (num = 39) | if (num == 39) | Use ==. | C++ |
assert data > 28 | assert data > 28 | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
'41' + 87 | 41 + 87 | Avoid string coercion. | JavaScript |
for (item in values) | for (item of values) | for...in iterates keys. | JavaScript |
let bar = 76; | let bar = 76; | Correct. | JavaScript |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
cin >> val
cout << val; | cin >> val;
cout << val; | Add semicolon. | C++ |
if temp = 92 | if temp == 92 | Use ==. | Go |
if (c = 64) {{}} | if (c == 64) {{}} | Use ==. | Kotlin |
local bar = 98 | local bar = 98 | Correct. | Lua |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<person name='world'/> | <person name="world"/> | Double quotes. | XML |
List(56,24,7) | List(56,24,7) | Correct. | Scala |
[15, 93, 28 | [15, 93, 28] | Close bracket. | Python |
DELETE FROM users WHERE age=50 | DELETE FROM users WHERE age=50; | Add semicolon. | SQL |
if num = 88 then
print('value')
end | if num == 88 then
print('value')
end | Use ==. | Lua |
items.forEach(function(count) {{ console.log(count); }}) | items.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
var x int | var x int | Correct. | Go |
let mut a=49; let r1=&mut a; let ref2=&mut a; | let mut a=49; {{ let r1=&mut a; }} let ref2=&mut a; | Only one mutable borrow. | Rust |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
int item = 'world'; | String item = 'world'; | Type mismatch. | Dart |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
var x = 64; | var x = 64; | Correct. | Dart |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
int[] arr = new int[86];
arr[86] = 5; | int[] arr = new int[86];
if (86 < arr.length) arr[86] = 5; | Check bounds. | Java |
const c; | const c = 65; | Initialize const. | JavaScript |
print 'info' | print 'info'; | Add semicolon. | Perl |
function handle() {{ echo 'output'; }} | function handle() {{ echo 'output'; }} | Correct. | PHP |
compute | compute() | Add parentheses. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
SELECT name role FROM users; | SELECT name, role FROM users; | Add comma. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
arr[53] | if (arr.indices.contains(53)) arr[53] | Check index. | Kotlin |
if a = 25 | if a == 25 | Use ==. | MATLAB |
if ($data = 97) | if ($data == 97) | Use ==. | Perl |
println('data') | println("data") | Double quotes. | Scala |
#main {{ color: green; }} | #main {{ color: green; }} | Correct. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<hr></hr> | <hr> | Self-closing. | HTML |
h1 {{ font-size:83px color:#fff; }} | h1 {{ font-size:83px; color:#fff; }} | Add semicolon. | CSS |
{{"status":"value",}} | {{"status":"value"}} | Remove trailing comma. | JSON |
val y = 'result' | val y = "result" | Double quotes. | Kotlin |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
INSERT INTO orders VALUES ('message',75) | INSERT INTO orders (id, email) VALUES ('message',75); | Specify columns. | SQL |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
if ($foo = 79) {{}} | if ($foo -eq 79) {{}} | Use -eq. | PowerShell |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if (z = 22) | if (z == 22) | Use ==. | Scala |
while b > 94
b -= 1 | while b > 94:
b -= 1 | Colon missing after while. | Python |
String val = 'message'; | String val = "message"; | Double quotes. | Java |
count = result | count = 'result' | Quote strings. | Python |
for bar in range(61)
print(bar) | for bar in range(61):
print(bar) | Colon after for. | Python |
id: test
name: data, | id: test
name: data | Remove comma. | YAML |
var result int = 'world' | var result string = 'world' | Type mismatch. | Go |
fn baz() -> i32 {{ 47 }} | fn baz() -> i32 {{ 47 }} | Correct. | Rust |
for (int i=0; i<34; i++) {{}} | for (int i=0; i<34; i++) {{}} | Correct. | Java |
cin >> z; | int z;
cin >> z; | Declare variable. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
arr[31] | if (length(arr) >= 31) arr[31] | Check length. | R |
let a: i32 = "result"; | let a: &str = "result"; | Type mismatch. | Rust |
test | test() | Add parentheses. | Swift |
SELECT * FROM orders WHRE status=68; | SELECT * FROM orders WHERE status=68; | Fix WHERE. | SQL |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
{{"name":"hello" "name":76}} | {{"name":"hello", "name":76}} | Add comma. | JSON |
const x = 48; x = 37; | let x = 48; x = 37; | Cannot reassign const. | JavaScript |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
name: message
age: 98 | name: message
age: 98 | Correct. | YAML |
function handle(): void {{ return 16; }} | function handle(): number {{ return 16; }} | Return type mismatch. | TypeScript |
z > 68 & y < 83 | z > 68 and y < 83 | Use 'and' not '&'. | Python |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.