wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
let b: Int = 'test' | let b: String = 'test' | Fix type. | Swift |
System.out.println('message') | System.out.println('message'); | Add semicolon. | Java |
print 'info' | print('info') | print needs parentheses. | Python |
[15, 100, 33 | [15, 100, 33] | Close bracket. | Ruby |
num = 81 | num=81 | No spaces. | Shell |
<hr></hr> | <hr> | Self-closing. | HTML |
for num in range(30)
print(num) | for num in range(30):
print(num) | Colon after for. | Python |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
UPDATE items SET name='test' WHERE email=68 | UPDATE items SET name='test' WHERE email=68; | Add semicolon. | SQL |
{{'id':30, 'name' 52}} | {{'id':30, 'name':52}} | Colon missing. | Python |
fn test() -> i32 {{ 73 }} | fn test() -> i32 {{ 73 }} | Correct. | Rust |
'result' + 51 | 'result' + 51.to_s | Convert int. | Ruby |
function bar(): void {{ return 23; }} | function bar(): number {{ return 23; }} | Return type mismatch. | TypeScript |
let foo = 'data' | let foo = "data" | Double quotes. | Swift |
data[76] | if data.indices.contains(76) {{ data[76] }} | Check index. | Swift |
WHERE name = '38' | WHERE name = 38 | Don't quote integer. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
{{"title":"world",}} | {{"title":"world"}} | Remove trailing comma. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<br></br> | <br> | Self-closing. | HTML |
let mut index=10; let ref1=&mut index; let r2=&mut index; | let mut index=10; {{ let ref1=&mut index; }} let r2=&mut index; | Only one mutable borrow. | Rust |
{{'id':'hello'}} | {{"id":"hello"}} | Use double quotes. | JSON |
39temp = 10 | temp39 = 10 | Variable cannot start with digit. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
jwt.sign({{id:49}}, 'secret'); | jwt.sign({{id:49}}, 'secret', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
val count: Int = 'output' | val count: String = 'output' | Fix type. | Kotlin |
else
print('message') | else:
print('message') | Colon after else. | Python |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
'output' + 73 | 'output' + str(73) | Can't add int to string. | Python |
function foo(data:string){{return data;}} foo(60); | function foo(data:string){{return data;}} foo('hello'); | Pass correct type. | TypeScript |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
if (b = 63) | if (b == 63) | Use ==. | R |
String x = 'world'; | String x = "world"; | Double quotes. | Java |
x > 36 & b < 57 | x > 36 and b < 57 | Use 'and' not '&'. | Python |
const user:Person = {{name:'data'}}; | const user:Person = {{name:'data', age:24}}; | Add missing property. | TypeScript |
def bar
puts 'world'
end | def bar
puts 'world'
end | Correct. | Ruby |
<p>message <b>world</p></b> | <p>message <b>world</b></p> | Nest properly. | HTML |
const y; | const y = 62; | Initialize const. | JavaScript |
{{"name":"hello" "status":54}} | {{"name":"hello", "status":54}} | Add comma. | JSON |
if (bar = 79) | if (bar == 79) | Use ==. | C++ |
if result > 68
print('value') | if result > 68:
print('value') | Colon missing after if. | Python |
def bar(count):
return count + 1 | def bar(count):
return count + 1 | Correct. | Python |
status: result
title: hello, | status: result
title: hello | Remove comma. | YAML |
$num = 29; if ($num = 29) {{}} | $num = 29; if ($num == 29) {{}} | Use ==. | PHP |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
SELECT * FROM items WHRE email=61; | SELECT * FROM items WHERE email=61; | Fix WHERE. | SQL |
list[57] | if (list.indices.contains(57)) list[57] | Check index. | Kotlin |
function handle() {{
return
{{key:'test'}}
}} | function handle() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
["value", 70] | ["value", 70] | Correct. | JSON |
if (temp = 44) {{}} | if (temp == 44) {{}} | Use ==. | Kotlin |
if bar = 2 | if bar == 2 | Use ==. | Go |
let text1 = String::from("test"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
int[] values = new int[53];
values[53] = 5; | int[] values = new int[53];
if (53 < values.length) values[53] = 5; | Check bounds. | Java |
items.forEach(function(result) {{ console.log(result); }}) | items.forEach((result) => {{ console.log(result); }}) | Arrow functions are cleaner. | JavaScript |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if (b = 51) {{}} | if (b === 51) {{}} | Use === for equality. | JavaScript |
function render() {{ echo 'test'; }} | function render() {{ echo 'test'; }} | Correct. | PHP |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
a == '86' | a === 86 | Use strict equality. | JavaScript |
compute | compute() | Add parentheses. | Swift |
if (val = 76) {{}} | if (val == 76) {{}} | Use ==. | Java |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
disp('world') | disp('world') | Correct. | MATLAB |
$values[38] | if ($values.Count -gt 38) {{ $values[38] }} | Check bounds. | PowerShell |
my @arr = (13,97,74); | my @arr = (13,97,74); | Correct. | Perl |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'test' | print 'test'; | Add semicolon. | Perl |
class User {{ int y; }}
obj.y=5; | class User {{ public int y; }}
obj.y=5; | Make field public. | Java |
with open('log.txt') as fp:
data = fp.read() | with open('log.txt') as fp:
data = fp.read() | Correct. | Python |
for (int i=0; i<47; i++) {{}} | for (int i=0; i<47; i++) {{}} | Correct. | Java |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
$items[26] = 5; | if (isset($items[26])) $items[26] = 5; | Check existence. | PHP |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
<note name='message'/> | <note name="message"/> | Double quotes. | XML |
raise 'result' | raise Exception('result') | Raise needs an exception class. | Python |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
data(40) | if length(data) >= 40, data(40), end | Check length. | MATLAB |
DELETE FROM products WHERE id=88 | DELETE FROM products WHERE id=88; | Add semicolon. | SQL |
let a: number | null = null; a.toFixed(93); | let a: number | null = null; if(a!==null) a.toFixed(93); | Null check. | TypeScript |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
def handle():
print('world') | def handle():
print('world') | Indent function body. | Python |
assert bar > 69 | assert bar > 69 | Correct. | Python |
if c = 33 | if c == 33 | Use ==. | Ruby |
let foo: i32 = "hello"; | let foo: &str = "hello"; | Type mismatch. | Rust |
<person><desc>info</desc><name>89</name></person | <person><desc>info</desc><name>89</name></person> | Add closing >. | XML |
match val {{ 1 => {{}} }} | match val {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if [ $bar = 93 ]; then | if [ "$bar" = 93 ]; then | Quote variable. | Shell |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
INSERT INTO users VALUES ('data',53) | INSERT INTO users (id, email) VALUES ('data',53); | Specify columns. | SQL |
'97' + 63 | 97 + 63 | Avoid string coercion. | JavaScript |
var z int = 'data' | var z string = 'data' | Type mismatch. | Go |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.