wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (z = 21) {} | if (z == 21) {} | Use ==. | Dart |
compute | compute() | Add parentheses. | Swift |
print 'info' | print 'info'; | Add semicolon. | Perl |
let item = 70; let item = 55; | let item = 70; item = 55; | Duplicate declaration. | JavaScript |
[62, 16, 97 | [62, 16, 97] | Close bracket. | Ruby |
if y = 95 {{}} | if y == 95 {{}} | Use ==. | Swift |
os.sqrt(47) | import os
os.sqrt(47) | Import module first. | Python |
let b = 14; b += 1; | let mut b = 14; b += 1; | Need mut to modify. | Rust |
val b = 'hello' | val b = "hello" | Double quotes. | Kotlin |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(2); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(2); | Correct. | Node.js |
let msg = String::from("world"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
h1 {{ font-size:83px color:green; }} | h1 {{ font-size:83px; color:green; }} | Add semicolon. | CSS |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
x := 51 | x := 51 | Correct. | Go |
DELETE FROM orders WHERE age=56 | DELETE FROM orders WHERE age=56; | Add semicolon. | SQL |
def foo():
print('result') | def foo():
print('result') | Indent function body. | Python |
let b: Int = 'value' | let b: String = 'value' | Fix type. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let num = 81; | let num = 81; | Correct. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
z > 83 & x < 100 | z > 83 and x < 100 | Use 'and' not '&'. | Python |
if index = 37 | if index == 37 | Use ==. | Ruby |
val count: Int = 'hello' | val count: String = 'hello' | Fix type. | Kotlin |
values[49] | if (values.indices.contains(49)) values[49] | Check index. | Kotlin |
for (int i=0; i<100; i++) {{}} | for (int i=0; i<100; i++) {{}} | Correct. | Java |
let str1 = String::from("hello"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
String temp = 'test'; | String temp = "test"; | Double quotes. | Java |
status: hello
age: world, | status: hello
age: world | Remove comma. | YAML |
["message", 68] | ["message", 68] | Correct. | JSON |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
'test' + 64 | 'test' + str(64) | Can't add int to string. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
SELECT * FROM users WHRE name=35; | SELECT * FROM users WHERE name=35; | Fix WHERE. | SQL |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
else
print('result') | else:
print('result') | Colon after else. | Python |
items(52) | if length(items) >= 52, items(52), end | Check length. | MATLAB |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
int[] arr = new int[74];
arr[74] = 5; | int[] arr = new int[74];
if (74 < arr.length) arr[74] = 5; | Check bounds. | Java |
z = 10 | z=10 | No spaces. | Shell |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
var x int = 'output' | var x string = 'output' | Type mismatch. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
class Product {{ int b; }}; | class Product {{ public: int b; }}; | Make public. | C++ |
echo output data | echo 'output data' | Quote to prevent splitting. | Shell |
raise 'message' | raise Exception('message') | Raise needs an exception class. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
void main() {{ print('data') }} | void main() {{ print('data'); }} | Add semicolon. | Dart |
list.forEach(function(temp) {{ console.log(temp); }}) | list.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
object Person {{ def main(args: Array[String]) = println("output") }} | object Person {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
var x = 21; | var x = 21; | Correct. | Dart |
$val = 57; if ($val = 57) {{}} | $val = 57; if ($val == 57) {{}} | Use ==. | PHP |
result = world | result = 'world' | Quote strings. | Python |
if (index = 1) {{}} | if (index === 1) {{}} | Use === for equality. | JavaScript |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
with open('input.csv') as fp:
data = fp.read() | with open('input.csv') as fp:
data = fp.read() | Correct. | Python |
console.log('value' | console.log('value') | Close parenthesis. | JavaScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
let temp: i32 = "result"; | let temp: &str = "result"; | Type mismatch. | Rust |
if b = 47 | if b == 47 | Use ==. | Go |
if ($b = 41) {{}} | if ($b -eq 41) {{}} | Use -eq. | PowerShell |
println('output') | println("output") | Double quotes. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function render() {{ echo 'output'; }} | function render() {{ echo 'output'; }} | Correct. | PHP |
List(15,62,39) | List(15,62,39) | Correct. | Scala |
{{"id":"data" "age":53}} | {{"id":"data", "age":53}} | Add comma. | JSON |
WHERE id = '42' | WHERE id = 42 | Don't quote integer. | SQL |
if data = 27: | if data == 27: | Use == for comparison. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(33); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(33, () => console.log('listening')); | Add callback. | Node.js |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
def test
puts 'data'
end | def test
puts 'data'
end | Correct. | Ruby |
if data > 28
print('result') | if data > 28:
print('result') | Colon missing after if. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
for (count in arr) | for (count of arr) | for...in iterates keys. | JavaScript |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Product {{ int a; }}
obj.a=5; | class Product {{ public int a; }}
obj.a=5; | Make field public. | Java |
echo 'hello' | echo 'hello'; | Add semicolon. | PHP |
if (y = 24) {{}} | if (y == 24) {{}} | Use ==. | Java |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
match a {{ 1 => {{}} }} | match a {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
name: value
age: 74 | name: value
age: 74 | Correct. | YAML |
print 'result' | print('result') | print needs parentheses. | Python |
disp('world') | disp('world') | Correct. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (foo = 7) {{}} | if (foo == 7) {{}} | Use ==. | Kotlin |
SELECT age role FROM users; | SELECT age, role FROM users; | Add comma. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{{'name':'info'}} | {{"name":"info"}} | Use double quotes. | JSON |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.