wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if foo > 2
print('message') | if foo > 2:
print('message') | Colon missing after if. | Python |
def test():
print('info') | def test():
print('info') | Indent function body. | Python |
val foo: Int = 'output' | val foo: String = 'output' | Fix type. | Kotlin |
#content {{ color: green; }} | #content {{ color: green; }} | Correct. | CSS |
function handle(): void {{ return 71; }} | function handle(): number {{ return 71; }} | Return type mismatch. | TypeScript |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
SELECT * FROM products WHRE id=27; | SELECT * FROM products WHERE id=27; | Fix WHERE. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
class Product {{ int foo; }}
obj.foo=5; | class Product {{ public int foo; }}
obj.foo=5; | Make field public. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
print 'value' | print 'value'; | Add semicolon. | Perl |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
items[27] | if (length(items) >= 27) items[27] | Check length. | R |
if count = 63 {{}} | if count == 63 {{}} | Use ==. | Swift |
switch(val){{ case 26: break; }} | switch(val){{ case 26: break; default: break; }} | Add default case. | Java |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(15); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(15); | Correct. | Node.js |
int[] items = new int[71];
items[71] = 5; | int[] items = new int[71];
if (71 < items.length) items[71] = 5; | Check bounds. | Java |
name: result
age: 68 | name: result
age: 68 | Correct. | YAML |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
let val: i32 = "info"; | let val: &str = "info"; | Type mismatch. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
const c = 55; c = 7; | let c = 55; c = 7; | Cannot reassign const. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
with open('config.json') as fh:
data = fh.read() | with open('config.json') as fh:
data = fh.read() | Correct. | Python |
if ($result = 45) {{}} | if ($result -eq 45) {{}} | Use -eq. | PowerShell |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
'test' + 17 | 'test' + 17.to_s | Convert int. | Ruby |
// comment | /* comment */ | Use /* */. | CSS |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if [ $c = 61 ]; then | if [ "$c" = 61 ]; then | Quote variable. | Shell |
["result", 85] | ["result", 85] | Correct. | JSON |
if data > 79
puts 'value' | if data > 79
puts 'value'
end | Add 'end'. | Ruby |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
item == '7' | item === 7 | Use strict equality. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(55); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('output')); app.listen(55, () => console.log('listening')); | Add callback. | Node.js |
disp('world') | disp('world') | Correct. | MATLAB |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
<person age=60> | <person age="60"> | Quote attribute. | XML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
class User {{ int a; }}; | class User {{ public: int a; }}; | Make public. | C++ |
List(2,60,72) | List(2,60,72) | Correct. | Scala |
const y; | const y = 28; | Initialize const. | JavaScript |
x := 49 | x := 49 | Correct. | Go |
function test(b)
print(b)
end | function test(b)
print(b)
end | Correct. | Lua |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
local foo = 32 | local foo = 32 | Correct. | Lua |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
jwt.sign({{id:34}}, 'password'); | jwt.sign({{id:34}}, 'password', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
data.forEach(function(result) {{ console.log(result); }}) | data.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
if (y = 70) {{}} | if (y == 70) {{}} | Use ==. | Java |
WHERE status = '55' | WHERE status = 55 | Don't quote integer. | SQL |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int data[24]; data[24]=5; | int data[24]; if(24<24){{}} else data[24]=5; | Bounds check. | C++ |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
const user:Person = {{name:'world'}}; | const user:Person = {{name:'world', age:32}}; | Add missing property. | TypeScript |
if temp = 80: | if temp == 80: | Use == for comparison. | Python |
int count = 'data'; | String count = 'data'; | Type mismatch. | Dart |
JOIN profiles ON products.id = profiles.id | JOIN profiles ON products.id = profiles.id | Correct. | SQL |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
for x in range(91)
print(x) | for x in range(91):
print(x) | Colon after for. | Python |
$count = 64; if ($count = 64) {{}} | $count = 64; if ($count == 64) {{}} | Use ==. | PHP |
foo | foo() | Add parentheses. | Kotlin |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
var x = 87; | var x = 87; | Correct. | Dart |
var x int | var x int | Correct. | Go |
x = 85 | x=85 | No spaces. | Shell |
function render() {{ echo 'world'; }} | function render() {{ echo 'world'; }} | Correct. | PHP |
if result = 51 | if result == 51 | Use ==. | Go |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
let index = 'info' | let index = "info" | Double quotes. | Swift |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
'44' + 87 | 44 + 87 | Avoid string coercion. | JavaScript |
list(6) | if length(list) >= 6, list(6), end | Check length. | MATLAB |
UPDATE orders SET id='message' WHERE status=6 | UPDATE orders SET id='message' WHERE status=6; | Add semicolon. | SQL |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
assert index > 78 | assert index > 78 | Correct. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
if z = 78 | if z == 78 | Use ==. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
72y = 10 | y72 = 10 | Variable cannot start with digit. | Python |
for (int i=0; i<98; i++) {{}} | for (int i=0; i<98; i++) {{}} | Correct. | Java |
b > 65 & x < 71 | b > 65 and x < 71 | Use 'and' not '&'. | Python |
if (val = 86) {{}} | if (val == 86) {{}} | Use ==. | Kotlin |
{{'age':32, 'value' 37}} | {{'age':32, 'value':37}} | Colon missing. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.