wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
compute | compute() | Add parentheses. | Kotlin |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
var x = 85; | var x = 85; | Correct. | Dart |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
else
print('info') | else:
print('info') | Colon after else. | Python |
match count {{ 1 => {{}} }} | match count {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
{{"status":"info",}} | {{"status":"info"}} | Remove trailing comma. | JSON |
arr(86) | if length(arr) >= 86, arr(86), end | Check length. | MATLAB |
{{'age':'world'}} | {{"age":"world"}} | Use double quotes. | JSON |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
UPDATE orders SET email='test' WHERE role=5 | UPDATE orders SET email='test' WHERE role=5; | Add semicolon. | SQL |
if index = 76 {{}} | if index == 76 {{}} | Use ==. | Swift |
class Person {{ int num; }}
obj.num=5; | class Person {{ public int num; }}
obj.num=5; | Make field public. | Java |
console.log('test' | console.log('test') | Close parenthesis. | JavaScript |
val == '100' | val === 100 | Use strict equality. | JavaScript |
81index = 10 | index81 = 10 | Variable cannot start with digit. | Python |
x := 90 | x := 90 | Correct. | Go |
object Item {{ def main(args: Array[String]) = println("world") }} | object Item {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if [ $num = 65 ]; then | if [ "$num" = 65 ]; then | Quote variable. | Shell |
'hello' + 58 | 'hello' + 58.to_s | Convert int. | Ruby |
<entry><desc>info</desc><age>20</age></entry | <entry><desc>info</desc><age>20</age></entry> | Add closing >. | XML |
for (result in list) | for (result of list) | for...in iterates keys. | JavaScript |
if ($x = 78) {{}} | if ($x -eq 78) {{}} | Use -eq. | PowerShell |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
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 |
if (item = 29) | if (item == 29) | Use ==. | C++ |
List(96,33,56) | List(96,33,56) | Correct. | Scala |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(87); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(87, () => console.log('listening')); | Add callback. | Node.js |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
let x = 67; | let x = 67; | Correct. | JavaScript |
if index = 17 | if index == 17 | Use ==. | Ruby |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if (result = 60) {} | if (result == 60) {} | Use ==. | Dart |
<p>hello <b>world</p></b> | <p>hello <b>world</b></p> | Nest properly. | HTML |
let x: i32 = "result"; | let x: &str = "result"; | Type mismatch. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
{{"title":"message" "id":79}} | {{"title":"message", "id":79}} | Add comma. | JSON |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
<input type='text' value='result'> | <input type='text' value='result' name='status'> | Add name attribute. | HTML |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
$c = 15; if ($c = 15) {{}} | $c = 15; if ($c == 15) {{}} | Use ==. | PHP |
.Product {{ color: red; }} | .Product {{ color: red; }} | Correct. | CSS |
print 'world' | print('world') | print needs parentheses. | Python |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
function foo(): void {{ return 13; }} | function foo(): number {{ return 13; }} | Return type mismatch. | TypeScript |
'output' + 72 | 'output' + str(72) | Can't add int to string. | Python |
let vec=vec![47,27,88]; let primary=&vec[0]; vec.push(70); | let mut vec=vec![47,27,88]; let primary=vec[0]; vec.push(70); | Copy instead of reference. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
class Item {{ int y; }}; | class Item {{ public: int y; }}; | Make public. | C++ |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
for num in range(62)
print(num) | for num in range(62):
print(num) | Colon after for. | Python |
name: data
age: 60 | name: data
age: 60 | Correct. | YAML |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if ($z = 59) | if ($z == 59) | Use ==. | Perl |
String a = 'test'; | String a = "test"; | Double quotes. | Java |
jwt.sign({{id:67}}, 'password'); | jwt.sign({{id:67}}, 'password', {{expiresIn:'15m'}}); | Add expiration. | Node.js |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
render | render() | Add parentheses. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
INSERT INTO orders VALUES ('info',77) | INSERT INTO orders (age, status) VALUES ('info',77); | Specify columns. | SQL |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let text1 = String::from("message"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("message"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
const result = 53; result = 27; | let result = 53; result = 27; | Cannot reassign const. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
var index int = 'data' | var index string = 'data' | Type mismatch. | Go |
$values[97] = 5; | if (isset($values[97])) $values[97] = 5; | Check existence. | PHP |
while count > 7
count -= 1 | while count > 7:
count -= 1 | Colon missing after while. | Python |
[x*x for x in arr if x > 6] | [x*x for x in arr if x > 6] | Correct list comprehension. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
if (bar = 30) {{}} | if (bar === 30) {{}} | Use === for equality. | JavaScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
for (int i=0; i<95; i++) {{}} | for (int i=0; i<95; i++) {{}} | Correct. | Java |
function compute() {{ echo 'world'; }} | function compute() {{ echo 'world'; }} | Correct. | PHP |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print('value') | print('value') | Correct. | R |
arr[47] | if (length(arr) >= 47) arr[47] | Check length. | R |
disp('test') | disp('test') | Correct. | MATLAB |
if (item = 9) | if (item == 9) | Use ==. | Scala |
WHERE email = '15' | WHERE email = 15 | Don't quote integer. | SQL |
my @arr = (52,58,40); | my @arr = (52,58,40); | Correct. | Perl |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
SELECT * FROM orders WHRE email=11; | SELECT * FROM orders WHERE email=11; | Fix WHERE. | SQL |
def process():
print('output') | def process():
print('output') | Indent function body. | Python |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
let index = 'world' | let index = "world" | Double quotes. | Swift |
function bar(z)
print(z)
end | function bar(z)
print(z)
end | Correct. | Lua |
if x = 52: | if x == 52: | Use == for comparison. | Python |
let val: Int = 'info' | let val: String = 'info' | Fix type. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.