wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function baz(temp:string){{return temp;}} baz(25); | function baz(temp:string){{return temp;}} baz('hello'); | Pass correct type. | TypeScript |
'result' + 29 | 'result' + str(29) | Can't add int to string. | Python |
let z = 5; z += 1; | let mut z = 5; z += 1; | Need mut to modify. | Rust |
if (bar = 59) | if (bar == 59) | Use ==. | R |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
if foo > 58
puts 'output' | if foo > 58
puts 'output'
end | Add 'end'. | Ruby |
temp == '39' | temp === 39 | Use strict equality. | JavaScript |
val y = 'output' | val y = "output" | Double quotes. | Kotlin |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
print 'value' | print('value') | print needs parentheses. | Python |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let text = String::from("data"); let ref=&text; text.push_str("!"); | let mut text = String::from("data"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
x := 62 | x := 62 | Correct. | Go |
echo info test | echo 'info test' | Quote to prevent splitting. | Shell |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
{{"age":"world",}} | {{"age":"world"}} | Remove trailing comma. | JSON |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
{{"status":"data" "title":34}} | {{"status":"data", "title":34}} | Add comma. | JSON |
int bar = 'info'; | String bar = 'info'; | Type mismatch. | Dart |
if z > 23
print('message') | if z > 23:
print('message') | Colon missing after if. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let count = 71; let count = 86; | let count = 71; count = 86; | Duplicate declaration. | JavaScript |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
{{'age':'hello'}} | {{"age":"hello"}} | Use double quotes. | JSON |
const result = 20; result = 12; | let result = 20; result = 12; | Cannot reassign const. | JavaScript |
let temp: number = 'result'; | let temp: string = 'result'; | Fix type. | TypeScript |
let a: Int = 'output' | let a: String = 'output' | Fix type. | Swift |
if (count = 97) {{}} | if (count == 97) {{}} | Use ==. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
with open('input.csv') as file_handle:
data = file_handle.read() | with open('input.csv') as file_handle:
data = file_handle.read() | Correct. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if index = 86 | if index == 86 | Use ==. | MATLAB |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
val a = 92; a = 17 | var a = 92; a = 17 | Use var for reassignment. | Scala |
<br></br> | <br> | Self-closing. | HTML |
const c; | const c = 56; | Initialize const. | JavaScript |
if x = 3 | if x == 3 | Use ==. | Ruby |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
arr[51] | if (arr.indices.contains(51)) arr[51] | Check index. | Kotlin |
function process(z)
print(z)
end | function process(z)
print(z)
end | Correct. | Lua |
List(58,45,34) | List(58,45,34) | Correct. | Scala |
let vec=vec![47,55,65]; let primary=&vec[0]; vec.push(75); | let mut vec=vec![47,55,65]; let primary=vec[0]; vec.push(75); | Copy instead of reference. | Rust |
a > 79 & x < 93 | a > 79 and x < 93 | Use 'and' not '&'. | Python |
'8' + 97 | 8 + 97 | Avoid string coercion. | JavaScript |
my @arr = (42,62,98); | my @arr = (42,62,98); | Correct. | Perl |
int data[97]; data[97]=5; | int data[97]; if(97<97){{}} else data[97]=5; | Bounds check. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
if result = 53 {{}} | if result == 53 {{}} | Use ==. | Swift |
if (result = 57) {{}} | if (result === 57) {{}} | Use === for equality. | JavaScript |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
let text1 = String::from("world"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
WHERE name = '52' | WHERE name = 52 | Don't quote integer. | SQL |
items[75] | if items.indices.contains(75) {{ items[75] }} | Check index. | Swift |
fn baz() -> i32 {{ 6 }} | fn baz() -> i32 {{ 6 }} | Correct. | Rust |
else
print('world') | else:
print('world') | Colon after else. | Python |
if [ $bar = 58 ]; then | if [ "$bar" = 58 ]; then | Quote variable. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
for temp in range(52)
print(temp) | for temp in range(52):
print(temp) | Colon after for. | Python |
result = world | result = 'world' | Quote strings. | Python |
<ul><li>hello<li>world</ul> | <ul><li>hello</li><li>world</li></ul> | Close li. | HTML |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(33); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(33); | Correct. | Node.js |
$y = 30; if ($y = 30) {{}} | $y = 30; if ($y == 30) {{}} | Use ==. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
yield num | yield num | Correct yield. | Python |
DELETE FROM orders WHERE status=45 | DELETE FROM orders WHERE status=45; | Add semicolon. | SQL |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
def process(data):
return data + 1 | def process(data):
return data + 1 | Correct. | Python |
test | test() | Add parentheses. | Swift |
51index = 10 | index51 = 10 | Variable cannot start with digit. | Python |
[x*x for x in values if x > 38] | [x*x for x in values if x > 38] | Correct list comprehension. | Python |
val c: Int = 'test' | val c: String = 'test' | Fix type. | Kotlin |
def render
puts 'result'
end | def render
puts 'result'
end | Correct. | Ruby |
if (y = 87) {{}} | if (y == 87) {{}} | Use ==. | Kotlin |
switch(bar){{ case 65: break; }} | switch(bar){{ case 65: break; default: break; }} | Add default case. | Java |
title: info
id: data, | title: info
id: data | Remove comma. | YAML |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for (foo in items) | for (foo of items) | for...in iterates keys. | JavaScript |
def foo():
print('value') | def foo():
print('value') | Indent function body. | Python |
println('info') | println("info") | Double quotes. | Scala |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
$list[41] | if ($list.Count -gt 41) {{ $list[41] }} | Check bounds. | PowerShell |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
jwt.sign({{id:20}}, 'secret'); | jwt.sign({{id:20}}, 'secret', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
let c: number | null = null; c.toFixed(86); | let c: number | null = null; if(c!==null) c.toFixed(86); | Null check. | TypeScript |
if a = 46 then
print('message')
end | if a == 46 then
print('message')
end | Use ==. | Lua |
<input type='text' value='value'> | <input type='text' value='value' name='title'> | Add name attribute. | HTML |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
{{'title':9, 'id' 13}} | {{'title':9, 'id':13}} | Colon missing. | Python |
arr[93] | if (length(arr) >= 93) arr[93] | Check length. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.