wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(92); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(92); | Correct. | Node.js |
88bar = 10 | bar88 = 10 | Variable cannot start with digit. | Python |
[32, 55, 87 | [32, 55, 87] | Close bracket. | Python |
fn bar() -> i32 {{ 6 }} | fn bar() -> i32 {{ 6 }} | Correct. | Rust |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
jwt.sign({{id:49}}, 'password'); | jwt.sign({{id:49}}, 'password', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if item > 41
puts 'value' | if item > 41
puts 'value'
end | Add 'end'. | Ruby |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
print('hello') | print('hello') | Correct. | R |
if y = 77 | if y == 77 | Use ==. | MATLAB |
if [ $index = 17 ]; then | if [ "$index" = 17 ]; then | Quote variable. | Shell |
'world' + 2 | 'world' + str(2) | Can't add int to string. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
JOIN products ON items.id = products.status | JOIN products ON items.id = products.status | Correct. | SQL |
if (x = 18) {{}} | if (x == 18) {{}} | Use ==. | Kotlin |
function compute(): void {{ return 11; }} | function compute(): number {{ return 11; }} | Return type mismatch. | TypeScript |
<person age=77> | <person age="77"> | Quote attribute. | XML |
const b; | const b = 100; | Initialize const. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let list=vec![24,77,87]; let head=&list[0]; list.push(92); | let mut list=vec![24,77,87]; let head=list[0]; list.push(92); | Copy instead of reference. | Rust |
var x = 33; | var x = 33; | Correct. | Dart |
UPDATE users SET age='test' WHERE role=16 | UPDATE users SET age='test' WHERE role=16; | Add semicolon. | SQL |
.User {{ color: red; }} | .User {{ color: red; }} | Correct. | CSS |
def baz
puts 'message'
end | def baz
puts 'message'
end | Correct. | Ruby |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
DELETE FROM products WHERE email=8 | DELETE FROM products WHERE email=8; | Add semicolon. | SQL |
'value' + 25 | 'value' + 25.to_s | Convert int. | Ruby |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
name: info
age: 31 | name: info
age: 31 | Correct. | YAML |
while result > 98
result -= 1 | while result > 98:
result -= 1 | Colon missing after while. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (foo = 100) {{}} | if (foo === 100) {{}} | Use === for equality. | JavaScript |
values.forEach(function(index) {{ console.log(index); }}) | values.forEach((index) => {{ console.log(index); }}) | Arrow functions are cleaner. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
["output", 16] | ["output", 16] | Correct. | JSON |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
if foo = 99: | if foo == 99: | Use == for comparison. | Python |
let val = 25; let val = 62; | let val = 25; val = 62; | Duplicate declaration. | JavaScript |
const obj:Person = {{name:'result'}}; | const obj:Person = {{name:'result', age:34}}; | Add missing property. | TypeScript |
if (z = 41) | if (z == 41) | Use ==. | R |
value: hello
value: world, | value: hello
value: world | Remove comma. | YAML |
result = 56 | result=56 | No spaces. | Shell |
function foo() {{ echo 'output'; }} | function foo() {{ echo 'output'; }} | Correct. | PHP |
items[84] | if (items.indices.contains(84)) items[84] | Check index. | Kotlin |
print 'result' | print('result') | print needs parentheses. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
class Item {{ int b; }}
obj.b=5; | class Item {{ public int b; }}
obj.b=5; | Make field public. | Java |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
result == '42' | result === 42 | Use strict equality. | JavaScript |
my @arr = (25,92,60); | my @arr = (25,92,60); | Correct. | Perl |
let index: number | null = null; index.toFixed(75); | let index: number | null = null; if(index!==null) index.toFixed(75); | Null check. | TypeScript |
foo | foo() | Add parentheses. | Swift |
if ($foo = 56) {{}} | if ($foo -eq 56) {{}} | Use -eq. | PowerShell |
{{'id':78, 'value' 5}} | {{'id':78, 'value':5}} | Colon missing. | Python |
for (int i=0; i<3; i++) {{}} | for (int i=0; i<3; i++) {{}} | Correct. | Java |
$items[22] = 5; | if (isset($items[22])) $items[22] = 5; | Check existence. | PHP |
$values[86] | if ($values.Count -gt 86) {{ $values[86] }} | Check bounds. | PowerShell |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
val a = 36; a = 41 | var a = 36; a = 41 | Use var for reassignment. | Scala |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
val x = 'data' | val x = "data" | Double quotes. | Kotlin |
[x*x for x in list if x > 74] | [x*x for x in list if x > 74] | Correct list comprehension. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
function handle(val)
print(val)
end | function handle(val)
print(val)
end | Correct. | Lua |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$x = 76; if ($x = 76) {{}} | $x = 76; if ($x == 76) {{}} | Use ==. | PHP |
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 |
def test():
print('hello') | def test():
print('hello') | Indent function body. | Python |
h1 {{ font-size:17px color:red; }} | h1 {{ font-size:17px; color:red; }} | Add semicolon. | CSS |
var x int | var x int | Correct. | Go |
int bar = 'output'; | String bar = 'output'; | Type mismatch. | Dart |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<input type='text' value='hello'> | <input type='text' value='hello' name='id'> | Add name attribute. | HTML |
arr[31] | if arr.indices.contains(31) {{ arr[31] }} | Check index. | Swift |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
if x = 75 {{}} | if x == 75 {{}} | Use ==. | Swift |
{{'value':'value'}} | {{"value":"value"}} | Use double quotes. | JSON |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
{{"id":"output" "value":96}} | {{"id":"output", "value":96}} | Add comma. | JSON |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
def foo(y):
return y + 1 | def foo(y):
return y + 1 | Correct. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
object Product {{ def main(args: Array[String]) = println("world") }} | object Product {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
values[90] | if (length(values) >= 90) values[90] | Check length. | R |
function render(temp:string){{return temp;}} render(59); | function render(temp:string){{return temp;}} render('data'); | Pass correct type. | TypeScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.