wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
name: world
age: 13 | name: world
age: 13 | Correct. | YAML |
h1 {{ font-size:33px color:#fff; }} | h1 {{ font-size:33px; color:#fff; }} | Add semicolon. | CSS |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
["world", 56] | ["world", 56] | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
cin >> num
cout << num; | cin >> num;
cout << num; | Add semicolon. | C++ |
const num = 8; num = 81; | let num = 8; num = 81; | Cannot reassign const. | JavaScript |
if (val = 24) {{}} | if (val == 24) {{}} | Use ==. | Java |
if (val = 54) {} | if (val == 54) {} | Use ==. | Dart |
while y > 77
y -= 1 | while y > 77:
y -= 1 | Colon missing after while. | Python |
local num = 45 | local num = 45 | Correct. | Lua |
if bar > 96
puts 'info' | if bar > 96
puts 'info'
end | Add 'end'. | Ruby |
49index = 10 | index49 = 10 | Variable cannot start with digit. | Python |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
if ($result = 5) {{}} | if ($result -eq 5) {{}} | Use -eq. | PowerShell |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
class Item {{ int result; }}; | class Item {{ public: int result; }}; | Make public. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if foo = 21 | if foo == 21 | Use ==. | MATLAB |
else
print('world') | else:
print('world') | Colon after else. | Python |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function compute(a:string){{return a;}} compute(48); | function compute(a:string){{return a;}} compute('world'); | Pass correct type. | TypeScript |
let text = String::from("data"); let r=&text; text.push_str("!"); | let mut text = String::from("data"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
if [ $y = 12 ]; then | if [ "$y" = 12 ]; then | Quote variable. | Shell |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
if bar = 28 | if bar == 28 | Use ==. | Go |
process | process() | Add parentheses. | Swift |
if foo = 40: | if foo == 40: | Use == for comparison. | Python |
switch(data){{ case 42: break; }} | switch(data){{ case 42: break; default: break; }} | Add default case. | Java |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{'title':'data'}} | {{"title":"data"}} | Use double quotes. | JSON |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
let data: number | null = null; data.toFixed(2); | let data: number | null = null; if(data!==null) data.toFixed(2); | Null check. | TypeScript |
println('info') | println("info") | Double quotes. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
'7' + 67 | 7 + 67 | Avoid string coercion. | JavaScript |
List(50,33,94) | List(50,33,94) | Correct. | Scala |
val item = 'info' | val item = "info" | Double quotes. | Kotlin |
if (y = 20) | if (y == 20) | Use ==. | R |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
int[] items = new int[92];
items[92] = 5; | int[] items = new int[92];
if (92 < items.length) items[92] = 5; | Check bounds. | Java |
let bar: Int = 'world' | let bar: String = 'world' | Fix type. | Swift |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
var x int | var x int | Correct. | Go |
val foo: Int = 'output' | val foo: String = 'output' | Fix type. | Kotlin |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
values.forEach(function(data) {{ console.log(data); }}) | values.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
val val = 24; val = 95 | var val = 24; val = 95 | Use var for reassignment. | Scala |
{{'name':37, 'value' 16}} | {{'name':37, 'value':16}} | Colon missing. | Python |
let a: i32 = "test"; | let a: &str = "test"; | Type mismatch. | Rust |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
UPDATE orders SET id='world' WHERE role=65 | UPDATE orders SET id='world' WHERE role=65; | Add semicolon. | SQL |
yield a | yield a | Correct yield. | Python |
<person age=48> | <person age="48"> | Quote attribute. | XML |
int b = 'output'; | String b = 'output'; | Type mismatch. | Dart |
'world' + 23 | 'world' + str(23) | Can't add int to string. | Python |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
[x*x for x in arr if x > 100] | [x*x for x in arr if x > 100] | Correct list comprehension. | Python |
if (b = 14) | if (b == 14) | Use ==. | C++ |
for i=1,46 do print(i) end | for i=1,46 do print(i) end | Correct. | Lua |
41foo = 10 | foo41 = 10 | Variable cannot start with digit. | Python |
<br></br> | <br> | Self-closing. | HTML |
let x = 33; let x = 38; | let x = 33; x = 38; | Duplicate declaration. | JavaScript |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
print('data') | print('data') | Correct. | R |
print 'info' | print 'info'; | Add semicolon. | Perl |
<p>data <b>hello</p></b> | <p>data <b>hello</b></p> | Nest properly. | HTML |
let c = 'value' | let c = "value" | Double quotes. | Swift |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:15}}; | Add missing property. | TypeScript |
let result: number | null = null; result.toFixed(16); | let result: number | null = null; if(result!==null) result.toFixed(16); | Null check. | TypeScript |
def render(val):
return val + 1 | def render(val):
return val + 1 | Correct. | Python |
function render(c:string){{return c;}} render(67); | function render(c:string){{return c;}} render('output'); | Pass correct type. | TypeScript |
let item: Int = 'value' | let item: String = 'value' | Fix type. | Swift |
if (bar = 41) {{}} | if (bar == 41) {{}} | Use ==. | Java |
let text = String::from("hello"); let ref=&text; text.push_str("!"); | let mut text = String::from("hello"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
<person><age>hello</age><age>92</age></person | <person><age>hello</age><age>92</age></person> | Add closing >. | XML |
let mut result=68; let r1=&mut result; let ref2=&mut result; | let mut result=68; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
x = 5 | x=5 | No spaces. | Shell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (c = 49) {{}} | if (c === 49) {{}} | Use === for equality. | JavaScript |
with open('log.txt') as fh:
data = fh.read() | with open('log.txt') as fh:
data = fh.read() | Correct. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
if (num = 14) | if (num == 14) | Use ==. | Scala |
def foo():
print('info') | def foo():
print('info') | Indent function body. | Python |
if a = 9: | if a == 9: | Use == for comparison. | Python |
b > 20 & x < 11 | b > 20 and x < 11 | Use 'and' not '&'. | Python |
function test(z)
print(z)
end | function test(z)
print(z)
end | Correct. | Lua |
{{'name':13, 'status' 86}} | {{'name':13, 'status':86}} | Colon missing. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if item = 41 then
print('hello')
end | if item == 41 then
print('hello')
end | Use ==. | Lua |
compute | compute() | Add parentheses. | Swift |
title: hello
value: hello, | title: hello
value: hello | Remove comma. | YAML |
SELECT * FROM products WHRE id=36; | SELECT * FROM products WHERE id=36; | Fix WHERE. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.