wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
function process(a)
print(a)
end | function process(a)
print(a)
end | Correct. | Lua |
function handle(temp:string){{return temp;}} handle(32); | function handle(temp:string){{return temp;}} handle('world'); | Pass correct type. | TypeScript |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
if (data) console.log('yes') else console.log('no') | if (data) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
else
print('value') | else:
print('value') | Colon after else. | Python |
if num = 84 | if num == 84 | Use ==. | Go |
object Order {{ def main(args: Array[String]) = println("data") }} | object Order {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
<hr></hr> | <hr> | Self-closing. | HTML |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
{{"status":"message" "id":49}} | {{"status":"message", "id":49}} | Add comma. | JSON |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
name: message
age: 25 | name: message
age: 25 | Correct. | YAML |
while item > 72
item -= 1 | while item > 72:
item -= 1 | Colon missing after while. | Python |
[16, 58, 55 | [16, 58, 55] | Close bracket. | Ruby |
def process():
print('test') | def process():
print('test') | Indent function body. | Python |
if ($foo = 73) {{}} | if ($foo -eq 73) {{}} | Use -eq. | PowerShell |
{{"value":"message",}} | {{"value":"message"}} | Remove trailing comma. | JSON |
if z = 22 {{}} | if z == 22 {{}} | Use ==. | Swift |
var x = 47; | var x = 47; | Correct. | Dart |
DELETE FROM orders WHERE age=84 | DELETE FROM orders WHERE age=84; | Add semicolon. | SQL |
.Order {{ color: red; }} | .Order {{ color: red; }} | Correct. | CSS |
function render() {{ echo 'hello'; }} | function render() {{ echo 'hello'; }} | Correct. | PHP |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:63}}; | Add missing property. | TypeScript |
$items[34] = 5; | if (isset($items[34])) $items[34] = 5; | Check existence. | PHP |
for i=1,94 do print(i) end | for i=1,94 do print(i) end | Correct. | Lua |
if (foo = 30) | if (foo == 30) | Use ==. | C++ |
cin >> temp; | int temp;
cin >> temp; | Declare variable. | C++ |
def compute
puts 'info'
end | def compute
puts 'info'
end | Correct. | Ruby |
let b = 18; b += 1; | let mut b = 18; b += 1; | Need mut to modify. | Rust |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x int | var x int | Correct. | Go |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
my @arr = (84,49,39); | my @arr = (84,49,39); | Correct. | Perl |
<person age=12> | <person age="12"> | Quote attribute. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
int item = 'value'; | String item = 'value'; | Type mismatch. | Dart |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
let b: number = 'data'; | let b: string = 'data'; | Fix type. | TypeScript |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
num == '32' | num === 32 | Use strict equality. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if z = 77 | if z == 77 | Use ==. | MATLAB |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
name: data
status: data, | name: data
status: data | Remove comma. | YAML |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
if foo > 6
print('message') | if foo > 6:
print('message') | Colon missing after if. | Python |
JOIN orders ON products.id = orders.age | JOIN orders ON products.id = orders.age | Correct. | SQL |
int data[26]; data[26]=5; | int data[26]; if(26<26){{}} else data[26]=5; | Bounds check. | C++ |
UPDATE users SET id='output' WHERE role=20 | UPDATE users SET id='output' WHERE role=20; | Add semicolon. | SQL |
print('result') | print('result') | Correct. | R |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
print 'hello' | print 'hello'; | Add semicolon. | Perl |
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 |
let y = 'value' | let y = "value" | Double quotes. | Swift |
if x = 88 then
print('output')
end | if x == 88 then
print('output')
end | Use ==. | Lua |
if ($result = 73) | if ($result == 73) | Use ==. | Perl |
INSERT INTO items VALUES ('output',76) | INSERT INTO items (name, status) VALUES ('output',76); | Specify columns. | SQL |
for (temp in data) | for (temp of data) | for...in iterates keys. | JavaScript |
yield temp | yield temp | Correct yield. | Python |
items[17] | if (length(items) >= 17) items[17] | Check length. | R |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
def handle(a):
return a + 1 | def handle(a):
return a + 1 | Correct. | Python |
let val: i32 = "message"; | let val: &str = "message"; | Type mismatch. | Rust |
x > 70 & x < 54 | x > 70 and x < 54 | Use 'and' not '&'. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
'13' + 48 | 13 + 48 | Avoid string coercion. | JavaScript |
[x*x for x in list if x > 66] | [x*x for x in list if x > 66] | Correct list comprehension. | Python |
{{'status':'data'}} | {{"status":"data"}} | Use double quotes. | JSON |
fn foo() -> i32 {{ 19 }} | fn foo() -> i32 {{ 19 }} | Correct. | Rust |
const item; | const item = 64; | Initialize const. | JavaScript |
let b: Int = 'result' | let b: String = 'result' | Fix type. | Swift |
if index = 50: | if index == 50: | Use == for comparison. | Python |
'data' + 35 | 'data' + str(35) | Can't add int to string. | Python |
baz | baz() | Add parentheses. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
<br></br> | <br> | Self-closing. | HTML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
val c: Int = 'world' | val c: String = 'world' | Fix type. | Kotlin |
foo = 48 | foo=48 | No spaces. | Shell |
if count = 91 | if count == 91 | Use ==. | Ruby |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
println('test') | println("test") | Double quotes. | Scala |
String c = 'message'; | String c = "message"; | Double quotes. | Java |
$values[48] | if ($values.Count -gt 48) {{ $values[48] }} | Check bounds. | PowerShell |
const x = 2; x = 66; | let x = 2; x = 66; | Cannot reassign const. | JavaScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.